diff options
-rw-r--r-- | java/CHANGES | 3 | ||||
-rw-r--r-- | java/build.xml | 3 | ||||
-rw-r--r-- | java/demo/Ice/value/Client.java | 11 | ||||
-rw-r--r-- | java/demo/Ice/value/InitialI.java | 6 | ||||
-rw-r--r-- | java/demo/Ice/value/Value.ice | 1 | ||||
-rw-r--r-- | java/src/Freeze/EvictorI.java | 2 | ||||
-rw-r--r-- | java/src/Ice/ObjectImpl.java | 2 | ||||
-rw-r--r-- | java/src/IceInternal/BasicStream.java | 20 | ||||
-rw-r--r-- | java/test/Ice/package/AllTests.java | 25 | ||||
-rw-r--r-- | java/test/Ice/package/Test.ice | 3 | ||||
-rw-r--r-- | java/test/Ice/slicing/objects/csrc/AllTests.java | 12 |
11 files changed, 25 insertions, 63 deletions
diff --git a/java/CHANGES b/java/CHANGES index c598ab80141..b37480a9e40 100644 --- a/java/CHANGES +++ b/java/CHANGES @@ -1,6 +1,9 @@ Changes since version 2.1.2 --------------------------- +- Ice.ObjectImpl is now an abstract class that cannot be instantiated. + This change should be transparent to application code. + - Added new features to the Java mapping: - Structures, classes, and exceptions now have one-shot constructors. diff --git a/java/build.xml b/java/build.xml index c2832a35024..fb59f713c14 100644 --- a/java/build.xml +++ b/java/build.xml @@ -69,6 +69,9 @@ <include name="EvictorStorage.ice" /> <include name="CatalogData.ice" /> </fileset> + <fileset dir="${src.dir}/Freeze"> + <include name="PingObject.ice" /> + </fileset> </slice2java> <slice2freezej outputdir="${generated.dir}" dependencyfile="${generated.dir}/.depend.Freeze"> diff --git a/java/demo/Ice/value/Client.java b/java/demo/Ice/value/Client.java index ee20db68051..999b63710a8 100644 --- a/java/demo/Ice/value/Client.java +++ b/java/demo/Ice/value/Client.java @@ -57,17 +57,6 @@ public class Client extends Ice.Application System.out.println("==> " + simple.message); System.out.println(); - System.out.println("Ok, this worked. Now let's try to transfer an object for a class"); - System.out.println("with operations as type Ice.Object. Because no factory is installed,"); - System.out.println("the class will be sliced to Ice.Object."); - System.out.println("[press enter]"); - readline(in); - - Ice.Object obj = initial.getPrinterAsObject(); - System.out.println("The type ID of the received object is \"" + obj.ice_id() + "\""); - assert(obj.ice_id().equals("::Ice::Object")); - - System.out.println(); System.out.println("Yes, this worked. Now let's try to transfer an object for a class"); System.out.println("with operations as type Demo.Printer, without installing a factory first."); System.out.println("This should give us a `no factory' exception."); diff --git a/java/demo/Ice/value/InitialI.java b/java/demo/Ice/value/InitialI.java index d7817f25873..bdcedc5ba8e 100644 --- a/java/demo/Ice/value/InitialI.java +++ b/java/demo/Ice/value/InitialI.java @@ -32,12 +32,6 @@ class InitialI extends Initial return _simple; } - public Ice.Object - getPrinterAsObject(Ice.Current current) - { - return _printer; - } - public void getPrinter(PrinterHolder impl, PrinterPrxHolder proxy, Ice.Current current) { diff --git a/java/demo/Ice/value/Value.ice b/java/demo/Ice/value/Value.ice index 9ea79f9fe08..d6d70f7b1ce 100644 --- a/java/demo/Ice/value/Value.ice +++ b/java/demo/Ice/value/Value.ice @@ -38,7 +38,6 @@ exception DerivedPrinterException class Initial { Simple getSimple(); - Object getPrinterAsObject(); void getPrinter(out Printer impl, out Printer* proxy); Printer getDerivedPrinter(); void throwDerivedPrinter() throws DerivedPrinterException; diff --git a/java/src/Freeze/EvictorI.java b/java/src/Freeze/EvictorI.java index 40a7298b121..1bd9f2b7b01 100644 --- a/java/src/Freeze/EvictorI.java +++ b/java/src/Freeze/EvictorI.java @@ -2300,6 +2300,6 @@ class EvictorI extends Ice.LocalObjectImpl implements Evictor, Runnable private boolean _deadlockWarning; - private Ice.Object _pingObject = new Ice.ObjectImpl(); + private Ice.Object _pingObject = new PingObject(); } diff --git a/java/src/Ice/ObjectImpl.java b/java/src/Ice/ObjectImpl.java index 839406b6c2f..f2ee108265f 100644 --- a/java/src/Ice/ObjectImpl.java +++ b/java/src/Ice/ObjectImpl.java @@ -9,7 +9,7 @@ package Ice; -public class ObjectImpl implements Object, java.lang.Cloneable +public abstract class ObjectImpl implements Object, java.lang.Cloneable { public ObjectImpl() diff --git a/java/src/IceInternal/BasicStream.java b/java/src/IceInternal/BasicStream.java index a08a1de1c6f..00154f06028 100644 --- a/java/src/IceInternal/BasicStream.java +++ b/java/src/IceInternal/BasicStream.java @@ -1271,6 +1271,15 @@ public class BasicStream { String id = readTypeId(); + // + // If we slice all the way down to Ice::Object, we throw + // because Ice::Object is abstract. + // + if(id.equals(Ice.ObjectImpl.ice_staticId())) + { + throw new Ice.NoObjectFactoryException("class sliced to Ice.Object, which is abstract", id); + } + // // Try to find a factory registered for the specific type. // @@ -1294,17 +1303,6 @@ public class BasicStream } // - // There isn't a static factory for Ice::Object, so check - // for that case now. We do this *after* the factory - // inquiries above so that a factory could be registered - // for "::Ice::Object". - // - if(v == null && id.equals(Ice.ObjectImpl.ice_staticId())) - { - v = new Ice.ObjectImpl(); - } - - // // Last chance: check the table of static factories (i.e., // automatically generated factories for concrete // classes). diff --git a/java/test/Ice/package/AllTests.java b/java/test/Ice/package/AllTests.java index df9a726fe6a..22a08342ded 100644 --- a/java/test/Ice/package/AllTests.java +++ b/java/test/Ice/package/AllTests.java @@ -104,27 +104,6 @@ public class AllTests System.out.flush(); { - Ice.Object o = initial.getTest2C2AsObject(); - test(o != null); - test(!(o instanceof testpkg.Test2.C1)); // Sliced to Ice.Object - try - { - initial.getTest2C2AsC1(); - test(false); - } - catch(Ice.NoObjectFactoryException ex) - { - // Expected - } - try - { - initial.getTest2C2AsC2(); - test(false); - } - catch(Ice.NoObjectFactoryException ex) - { - // Expected - } try { initial.throwTest2E2AsE1(); @@ -158,8 +137,6 @@ public class AllTests // Define Ice.Package.Test2=testpkg and try again. // communicator.getProperties().setProperty("Ice.Package.Test2", "testpkg"); - Ice.Object o = initial.getTest2C2AsObject(); - test(o != null); testpkg.Test2.C1 c1 = initial.getTest2C2AsC1(); test(c1 != null); test(c1 instanceof testpkg.Test2.C2); @@ -192,8 +169,6 @@ public class AllTests // have already been cached for them, so now we use the Test3.* types. // communicator.getProperties().setProperty("Ice.Default.Package", "testpkg"); - Ice.Object o = initial.getTest3C2AsObject(); - test(o != null); testpkg.Test3.C1 c1 = initial.getTest3C2AsC1(); test(c1 != null); test(c1 instanceof testpkg.Test3.C2); diff --git a/java/test/Ice/package/Test.ice b/java/test/Ice/package/Test.ice index afac22ab265..cd4f4b4390e 100644 --- a/java/test/Ice/package/Test.ice +++ b/java/test/Ice/package/Test.ice @@ -14,20 +14,17 @@ module Test { interface Initial { - Object getTest1C2AsObject(); Test1::C1 getTest1C2AsC1(); Test1::C2 getTest1C2AsC2(); void throwTest1E2AsE1() throws Test1::E1; void throwTest1E2AsE2() throws Test1::E2; void throwTest1Notify() throws Test1::notify; - Object getTest2C2AsObject(); Test2::C1 getTest2C2AsC1(); Test2::C2 getTest2C2AsC2(); void throwTest2E2AsE1() throws Test2::E1; void throwTest2E2AsE2() throws Test2::E2; - Object getTest3C2AsObject(); Test3::C1 getTest3C2AsC1(); Test3::C2 getTest3C2AsC2(); void throwTest3E2AsE1() throws Test3::E1; diff --git a/java/test/Ice/slicing/objects/csrc/AllTests.java b/java/test/Ice/slicing/objects/csrc/AllTests.java index 98352ac238d..91b20fc9fa2 100644 --- a/java/test/Ice/slicing/objects/csrc/AllTests.java +++ b/java/test/Ice/slicing/objects/csrc/AllTests.java @@ -225,14 +225,15 @@ public class AllTests public void ice_response(Ice.Object o) { - test(o.ice_id().equals("::Ice::Object")); - callback.called(); + test(false); } public void ice_exception(Ice.LocalException exc) { - test(false); + + test(exc.ice_name().equals("Ice::NoObjectFactoryException")); + callback.called(); } public void @@ -1142,7 +1143,10 @@ public class AllTests try { o = test.SUnknownAsObject(); - test(o.ice_id().equals("::Ice::Object")); + test(false); + } + catch(Ice.NoObjectFactoryException ex) + { } catch(Exception ex) { |