PatchSet 3963 Date: 2003/08/20 06:19:15 Author: guilhem Branch: HEAD Tag: (none) Log: RMI/Serialization fix. resolveClass called after reading fields in readClassDescriptor.
This fix includes also a slight code cleanup in the method. Members: ChangeLog:1.1561->1.1562 libraries/javalib/java/io/ObjectInputStream.java:1.23->1.24 Index: kaffe/ChangeLog diff -u kaffe/ChangeLog:1.1561 kaffe/ChangeLog:1.1562 --- kaffe/ChangeLog:1.1561 Tue Aug 19 10:30:22 2003 +++ kaffe/ChangeLog Wed Aug 20 06:19:15 2003 @@ -1,3 +1,10 @@ +2003-08-20 Guilhem Lavaux <[EMAIL PROTECTED]> + + * libraries/javalib/java/io/ObjectInputStream.java: + (readClassDescriptor) call resolveClass(ObjectStreamClass) + at the right moment ant not resolveClass(String) at the top of + the method. This could cause problems in RMI. + 2003-08-19 Guilhem Lavaux <[EMAIL PROTECTED]> * libraries/javalib/java/text/RuleBasedCollator.java: Index: kaffe/libraries/javalib/java/io/ObjectInputStream.java diff -u kaffe/libraries/javalib/java/io/ObjectInputStream.java:1.23 kaffe/libraries/javalib/java/io/ObjectInputStream.java:1.24 --- kaffe/libraries/javalib/java/io/ObjectInputStream.java:1.23 Thu Aug 14 17:07:51 2003 +++ kaffe/libraries/javalib/java/io/ObjectInputStream.java Wed Aug 20 06:19:16 2003 @@ -426,12 +426,13 @@ byte flags = this.realInputStream.readByte (); 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); + dumpElementln("CLASSDESC NAME=" + name + "; UID=" + Long.toHexString(uid) + + "; FLAGS=" + Integer.toHexString(flags) + "; FIELD COUNT=" + + field_count); int real_count = 0; for (int i=0; i < field_count; i++) @@ -469,38 +470,32 @@ class_name = String.valueOf (type_code); of = new ObjectStreamField (field_name, class_name); } - + + fields[i] = of; + } + + /* Now that fields have been read we may resolve the class + * (and read annotation if needed). */ + Class clazz = resolveClass(osc); + + for (int i=0; i < field_count; i++) + { Field f; + try - { - f = clazz.getDeclaredField (field_name); - 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 + " (requested was \"" + of.getType() + " and found \"" + f.getType() + "\")"); - } + { + f = clazz.getDeclaredField (fields[i].getName()); + if (f != null && !f.getType().equals(fields[i].getType())) + throw new InvalidClassException("invalid field type for " + + fields[i].getName() + " in class " + name + + " (requested was \"" + fields[i].getType() + + " and found \"" + f.getType() + "\")"); + } catch (NoSuchFieldException _) - { - } - - fields[real_count] = of; - real_count++; - + { + } } - if (real_count != fields.length) - { - ObjectStreamField[] new_fields = new ObjectStreamField[real_count]; - - 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; - boolean oldmode = setBlockDataMode (true); osc.setClass (clazz, lookupClass(clazz.getSuperclass())); classLookupTable.put (clazz, osc); _______________________________________________ kaffe mailing list [EMAIL PROTECTED] http://kaffe.org/cgi-bin/mailman/listinfo/kaffe