summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2003-05-23 08:07:40 +0000
committerMichi Henning <michi@zeroc.com>2003-05-23 08:07:40 +0000
commit5c89803b442f059bd7444b286adb3e0a1c4afeca (patch)
treee79bae21964782dc9a89df7ae2d0985caa822c26 /java/src
parentVC70 install improvements (diff)
downloadice-5c89803b442f059bd7444b286adb3e0a1c4afeca.tar.bz2
ice-5c89803b442f059bd7444b286adb3e0a1c4afeca.tar.xz
ice-5c89803b442f059bd7444b286adb3e0a1c4afeca.zip
Fixed the bug that Benoit found yesterday in both ice and icej.
(Zero-length sequence containing class elements caused an crash.) :Ice::Object). Obviously, this would cause an assertion failure or a {{{ClassCastException}}}. The solution is simply to force the down-cast in the generated patch function and to check whether the cast failed: if so, the class was sliced too much and we throw a {{{NoObjectFactoryException}}} as we should. (For Java, the exception is thrown from {{{BasicStream.readObject}}}, after catching a {{{ClassCastException}}}. For C++, the exception is thrown directly from the generated patch function.) :Ice::Object}}} and {{{::Printer}}}. Updated the code generator to correctly initialize the {{{type}}} member of a {{{NoObjectFactoryException}}} with the type ID of the type that wasn't found. (Unfortunately, this involved modifying {{{Parser.h}}}, so you will have to rebuild both ice and icej.) Added code generation for custom sequence types for icej. Generated code compiles and looks OK, but I haven't written tests yet, so there may still be a latent bug in this.
Diffstat (limited to 'java/src')
-rw-r--r--java/src/Ice/ObjectHolder.java6
-rw-r--r--java/src/Ice/ObjectImpl.java8
-rw-r--r--java/src/IceInternal/BasicStream.java6
-rw-r--r--java/src/IceInternal/Patcher.java3
4 files changed, 19 insertions, 4 deletions
diff --git a/java/src/Ice/ObjectHolder.java b/java/src/Ice/ObjectHolder.java
index 9d1ad91e088..5d88becf0b9 100644
--- a/java/src/Ice/ObjectHolder.java
+++ b/java/src/Ice/ObjectHolder.java
@@ -34,6 +34,12 @@ public final class ObjectHolder
{
value = v;
}
+
+ public String
+ type()
+ {
+ return Ice.ObjectImpl.ice_staticId();
+ }
}
public Patcher
diff --git a/java/src/Ice/ObjectImpl.java b/java/src/Ice/ObjectImpl.java
index 551ae4de307..eec827b0217 100644
--- a/java/src/Ice/ObjectImpl.java
+++ b/java/src/Ice/ObjectImpl.java
@@ -198,7 +198,7 @@ public class ObjectImpl implements Object, java.lang.Cloneable
{
synchronized(_activeFacetMap)
{
- __os.writeTypeId("::Ice::Object");
+ __os.writeTypeId(ice_staticId());
__os.startWriteSlice();
final int sz = _activeFacetMap.size();
__os.writeSize(sz);
@@ -228,6 +228,12 @@ public class ObjectImpl implements Object, java.lang.Cloneable
_activeFacetMap.put(__key, v);
}
+ public String
+ type()
+ {
+ return ice_staticId();
+ }
+
private String __key;
}
diff --git a/java/src/IceInternal/BasicStream.java b/java/src/IceInternal/BasicStream.java
index c157d980dae..09e68ff2f9a 100644
--- a/java/src/IceInternal/BasicStream.java
+++ b/java/src/IceInternal/BasicStream.java
@@ -1116,7 +1116,7 @@ public class BasicStream
while(true)
{
String id = readTypeId();
- if(id.equals("::Ice::Object"))
+ if(id.equals(Ice.ObjectImpl.ice_staticId()))
{
v = new Ice.ObjectImpl();
}
@@ -1323,7 +1323,9 @@ public class BasicStream
}
catch(ClassCastException ex)
{
- throw new Ice.UnmarshalOutOfBoundsException();
+ Ice.NoObjectFactoryException nof = new Ice.NoObjectFactoryException();
+ nof.type = p.type();
+ throw nof;
}
}
diff --git a/java/src/IceInternal/Patcher.java b/java/src/IceInternal/Patcher.java
index 11fdbf06adb..b5e30377bd0 100644
--- a/java/src/IceInternal/Patcher.java
+++ b/java/src/IceInternal/Patcher.java
@@ -17,4 +17,5 @@ package IceInternal;
public interface Patcher
{
void patch(Ice.Object v);
-};
+ String type();
+}