[kaffe] CVS kaffe (guilhem): Deserialization fix.
Kaffe CVS
cvs-commits at kaffe.org
Thu Aug 14 10:13:02 PDT 2003
PatchSet 3947
Date: 2003/08/14 18:07:51
Author: guilhem
Branch: HEAD
Tag: (none)
Log:
Deserialization fix.
Use resolveClass to solve types of field in classes. Before Class.forName
was used in TypeSignature and was not reliable to obtain the right classes.
(Alias failure).
Interface does not change so regenerating bootstrap is not necessary.
Members:
ChangeLog:1.1549->1.1550
libraries/javalib/java/io/ObjectInputStream.java:1.22->1.23
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1549 kaffe/ChangeLog:1.1550
--- kaffe/ChangeLog:1.1549 Thu Aug 14 07:23:40 2003
+++ kaffe/ChangeLog Thu Aug 14 10:07:51 2003
@@ -1,3 +1,10 @@
+2003-08-14 Guilhem Lavaux <guilhem at kaffe.org>
+
+ * libraries/javalib/java/io/ObjectInputStream.java:
+ (readClassDescriptor) use resolveClass to solve field type in the
+ special case where the type is a true object. If it is a primitive
+ fall back on the default behaviour.
+
2003-08-14 Rob Gonzalez <rob at kaffe.org>
* kaffe/kaffevm/verify.h
Index: kaffe/libraries/javalib/java/io/ObjectInputStream.java
diff -u kaffe/libraries/javalib/java/io/ObjectInputStream.java:1.22 kaffe/libraries/javalib/java/io/ObjectInputStream.java:1.23
--- kaffe/libraries/javalib/java/io/ObjectInputStream.java:1.22 Tue Aug 12 00:02:21 2003
+++ kaffe/libraries/javalib/java/io/ObjectInputStream.java Thu Aug 14 10:07:51 2003
@@ -427,6 +427,9 @@
short field_count = this.realInputStream.readShort ();
ObjectStreamField[] fields = new ObjectStreamField[field_count];
Class clazz = resolveClass(name);
+ ObjectStreamClass osc = new ObjectStreamClass (name, uid,
+ flags, fields);
+ assignNewHandle (osc);
dumpElementln("CLASSDESC NAME=" + name + "; UID=" + Long.toHexString(uid) + "; FLAGS=" + Integer.toHexString(flags) + "; FIELD COUNT=" + field_count);
@@ -438,17 +441,35 @@
String class_name;
dumpElementln (" TYPE CODE=" + type_code + "; FIELD NAME=" + field_name);
-
+
+ ObjectStreamField of;
+
+ // There're many cases you can't get java.lang.Class from
+ // typename if your context class loader can't load it,
+ // then use typename to construct the field
+ // GL => No. You lose the capability to access the class loader.
+ // Type resolution must be done here. If it is an object we
+ // create the class just here if it is something else we delegate
+ // to TypeSignature.
if (type_code == 'L' || type_code == '[')
+ {
class_name = (String)readObject ();
+ /* We need to fully resolve only when an object is concerned.
+ * in the other case just use TypeSignature
+ */
+ if (class_name.charAt(0) == 'L')
+ of = new ObjectStreamField (field_name,
+ resolveClass(class_name.substring(1,
+ class_name.length()-1)));
+ else
+ of = new ObjectStreamField (field_name, class_name);
+ }
else
+ {
class_name = String.valueOf (type_code);
+ of = new ObjectStreamField (field_name, class_name);
+ }
- // There're many cases you can't get java.lang.Class from
- // typename if your context class loader can't load it,
- // then use typename to construct the field
- ObjectStreamField of =
- new ObjectStreamField (field_name, class_name);
Field f;
try
{
@@ -456,7 +477,7 @@
if (f == null)
throw new NoSuchFieldException();
if (!f.getType().equals(of.getType()))
- throw new InvalidClassException("invalid field type for " + field_name + " in class " + class_name);
+ throw new InvalidClassException("invalid field type for " + field_name + " in class " + class_name + " (requested was \"" + of.getType() + " and found \"" + f.getType() + "\")");
}
catch (NoSuchFieldException _)
{
@@ -473,11 +494,13 @@
System.arraycopy(fields, 0, new_fields, 0, real_count);
fields = new_fields;
}
+
+ /* Just before computing fields related parameters we must
+ * update it in the descriptor according to the just computed
+ * adaptation.
+ */
+ osc.fields = fields;
- ObjectStreamClass osc = new ObjectStreamClass (name, uid,
- flags, fields);
- assignNewHandle (osc);
-
boolean oldmode = setBlockDataMode (true);
osc.setClass (clazz, lookupClass(clazz.getSuperclass()));
classLookupTable.put (clazz, osc);
@@ -1882,8 +1905,6 @@
{
Field f = getField (klass, field_name);
ObjectStreamField of = new ObjectStreamField(field_name, f.getType());
-
- System.out.println("f=" + field_name + " rf=" + f.getName() + " rt=" + of.getTypeString() + " t=" + type_code);
if (of.getTypeString() == null ||
!of.getTypeString().equals(type_code))
More information about the kaffe
mailing list