From 04562e6b1c585a68a8278bd83e3a521546efa117 Mon Sep 17 00:00:00 2001 From: aph Date: Thu, 26 Apr 2007 14:31:29 +0000 Subject: 2007-04-25 Andrew Haley * java/io/ObjectStreamClass.java (ensureFieldsSet): New method. (setFields): call ensureFieldsSet. (fieldsSet): New field. * java/io/ObjectOutputStream.java (writeFields): Call osc.ensureFieldsSet(). * java/io/ObjectInputStream.java (parseContent): Assign the handle for a PROXYCLASSDESC immediately after reading the marker. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@124187 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/classpath/java/io/ObjectInputStream.java | 13 +++++++++++- libjava/classpath/java/io/ObjectOutputStream.java | 8 ++++++- libjava/classpath/java/io/ObjectStreamClass.java | 23 +++++++++++++++++++++ .../lib/java/io/ObjectInputStream$1.class | Bin 1152 -> 1152 bytes .../lib/java/io/ObjectInputStream$2.class | Bin 6148 -> 6148 bytes .../lib/java/io/ObjectInputStream$GetField.class | Bin 1025 -> 1025 bytes .../ObjectInputStream$ValidatorAndPriority.class | Bin 786 -> 786 bytes .../classpath/lib/java/io/ObjectInputStream.class | Bin 29540 -> 29581 bytes .../classpath/lib/java/io/ObjectOutputStream.class | Bin 18158 -> 18198 bytes .../lib/java/io/ObjectStreamClass$1.class | Bin 946 -> 946 bytes .../lib/java/io/ObjectStreamClass$2.class | Bin 834 -> 834 bytes .../io/ObjectStreamClass$InterfaceComparator.class | Bin 862 -> 862 bytes .../io/ObjectStreamClass$MemberComparator.class | Bin 1121 -> 1121 bytes .../classpath/lib/java/io/ObjectStreamClass.class | Bin 17794 -> 17956 bytes libjava/java/io/ObjectStreamClass.h | 4 ++++ 15 files changed, 46 insertions(+), 2 deletions(-) diff --git a/libjava/classpath/java/io/ObjectInputStream.java b/libjava/classpath/java/io/ObjectInputStream.java index e469609bde0..735d46cd920 100644 --- a/libjava/classpath/java/io/ObjectInputStream.java +++ b/libjava/classpath/java/io/ObjectInputStream.java @@ -223,6 +223,15 @@ public class ObjectInputStream extends InputStream case TC_PROXYCLASSDESC: { if(dump) dumpElementln("PROXYCLASS"); + +/* GCJ LOCAL */ + // The grammar at this point is + // TC_PROXYCLASSDESC newHandle proxyClassDescInfo + // i.e. we have to assign the handle immediately after + // reading the marker. + int handle = assignNewHandle("Dummy proxy"); +/* END GCJ LOCAL */ + int n_intf = this.realInputStream.readInt(); String[] intfs = new String[n_intf]; for (int i = 0; i < n_intf; i++) @@ -250,7 +259,9 @@ public class ObjectInputStream extends InputStream new InternalError("Object ctor missing").initCause(x); } } - assignNewHandle(osc); +/* GCJ LOCAL */ + rememberHandle(osc,handle); +/* END GCJ LOCAL */ if (!is_consumed) { diff --git a/libjava/classpath/java/io/ObjectOutputStream.java b/libjava/classpath/java/io/ObjectOutputStream.java index eac11f78db9..316b9070133 100644 --- a/libjava/classpath/java/io/ObjectOutputStream.java +++ b/libjava/classpath/java/io/ObjectOutputStream.java @@ -1211,11 +1211,17 @@ public class ObjectOutputStream extends OutputStream } +/* GCJ LOCAL */ // writes out FIELDS of OBJECT for the specified ObjectStreamClass. - // FIELDS are already in canonical order. + // FIELDS are already supposed already to be in canonical order, but + // under some circumstances (to do with Proxies) this isn't the + // case, so we call ensureFieldsSet(). private void writeFields(Object obj, ObjectStreamClass osc) throws IOException { + osc.ensureFieldsSet(osc.forClass()); +/* END GCJ LOCAL */ + ObjectStreamField[] fields = osc.fields; boolean oldmode = setBlockDataMode(false); diff --git a/libjava/classpath/java/io/ObjectStreamClass.java b/libjava/classpath/java/io/ObjectStreamClass.java index 52a1ad42873..cc3d0a9e31f 100644 --- a/libjava/classpath/java/io/ObjectStreamClass.java +++ b/libjava/classpath/java/io/ObjectStreamClass.java @@ -654,11 +654,29 @@ outer: flags |= ObjectStreamConstants.SC_ENUM; } +/* GCJ LOCAL */ + // FIXME: This is a workaround for a fairly obscure bug that happens + // when reading a Proxy and then writing it back out again. The + // result is that the ObjectStreamClass doesn't have its fields set, + // generating a NullPointerException. Rather than this kludge we + // should probably fix the real bug, but it would require a fairly + // radical reorganization to do so. + final void ensureFieldsSet(Class cl) + { + if (! fieldsSet) + setFields(cl); + } +/* END GCJ LOCAL */ + // Sets fields to be a sorted array of the serializable fields of // clazz. private void setFields(Class cl) { +/* GCJ LOCAL */ + fieldsSet = true; +/* END GCJ LOCAL */ + SetAccessibleAction setAccessible = new SetAccessibleAction(); if (!isSerializable() || isExternalizable() || isEnum()) @@ -1094,6 +1112,11 @@ outer: boolean isProxyClass = false; +/* GCJ LOCAL */ + // True after setFields() has been called + private boolean fieldsSet = false; +/* END GCJ LOCAL */ + // This is probably not necessary because this class is special cased already // but it will avoid showing up as a discrepancy when comparing SUIDs. private static final long serialVersionUID = -6120832682080437368L; diff --git a/libjava/classpath/lib/java/io/ObjectInputStream$1.class b/libjava/classpath/lib/java/io/ObjectInputStream$1.class index 43e3a0c23fc..d800fe4c61d 100644 Binary files a/libjava/classpath/lib/java/io/ObjectInputStream$1.class and b/libjava/classpath/lib/java/io/ObjectInputStream$1.class differ diff --git a/libjava/classpath/lib/java/io/ObjectInputStream$2.class b/libjava/classpath/lib/java/io/ObjectInputStream$2.class index 053a354bde5..d723177725c 100644 Binary files a/libjava/classpath/lib/java/io/ObjectInputStream$2.class and b/libjava/classpath/lib/java/io/ObjectInputStream$2.class differ diff --git a/libjava/classpath/lib/java/io/ObjectInputStream$GetField.class b/libjava/classpath/lib/java/io/ObjectInputStream$GetField.class index da4ee377470..e93a33030a2 100644 Binary files a/libjava/classpath/lib/java/io/ObjectInputStream$GetField.class and b/libjava/classpath/lib/java/io/ObjectInputStream$GetField.class differ diff --git a/libjava/classpath/lib/java/io/ObjectInputStream$ValidatorAndPriority.class b/libjava/classpath/lib/java/io/ObjectInputStream$ValidatorAndPriority.class index 20eacdb3b2b..06cec269ed1 100644 Binary files a/libjava/classpath/lib/java/io/ObjectInputStream$ValidatorAndPriority.class and b/libjava/classpath/lib/java/io/ObjectInputStream$ValidatorAndPriority.class differ diff --git a/libjava/classpath/lib/java/io/ObjectInputStream.class b/libjava/classpath/lib/java/io/ObjectInputStream.class index 9cc3755a53f..2c61cc687cf 100644 Binary files a/libjava/classpath/lib/java/io/ObjectInputStream.class and b/libjava/classpath/lib/java/io/ObjectInputStream.class differ diff --git a/libjava/classpath/lib/java/io/ObjectOutputStream.class b/libjava/classpath/lib/java/io/ObjectOutputStream.class index 2ab5f486baa..472096945b0 100644 Binary files a/libjava/classpath/lib/java/io/ObjectOutputStream.class and b/libjava/classpath/lib/java/io/ObjectOutputStream.class differ diff --git a/libjava/classpath/lib/java/io/ObjectStreamClass$1.class b/libjava/classpath/lib/java/io/ObjectStreamClass$1.class index 6279a244cd8..8b3cbb0f527 100644 Binary files a/libjava/classpath/lib/java/io/ObjectStreamClass$1.class and b/libjava/classpath/lib/java/io/ObjectStreamClass$1.class differ diff --git a/libjava/classpath/lib/java/io/ObjectStreamClass$2.class b/libjava/classpath/lib/java/io/ObjectStreamClass$2.class index 4c91ea650b2..18a1c61b270 100644 Binary files a/libjava/classpath/lib/java/io/ObjectStreamClass$2.class and b/libjava/classpath/lib/java/io/ObjectStreamClass$2.class differ diff --git a/libjava/classpath/lib/java/io/ObjectStreamClass$InterfaceComparator.class b/libjava/classpath/lib/java/io/ObjectStreamClass$InterfaceComparator.class index 7c0ac37ee2f..babf58570de 100644 Binary files a/libjava/classpath/lib/java/io/ObjectStreamClass$InterfaceComparator.class and b/libjava/classpath/lib/java/io/ObjectStreamClass$InterfaceComparator.class differ diff --git a/libjava/classpath/lib/java/io/ObjectStreamClass$MemberComparator.class b/libjava/classpath/lib/java/io/ObjectStreamClass$MemberComparator.class index 233aa690ae4..527fd88ab9f 100644 Binary files a/libjava/classpath/lib/java/io/ObjectStreamClass$MemberComparator.class and b/libjava/classpath/lib/java/io/ObjectStreamClass$MemberComparator.class differ diff --git a/libjava/classpath/lib/java/io/ObjectStreamClass.class b/libjava/classpath/lib/java/io/ObjectStreamClass.class index e0d9e7f21b2..da622eb8947 100644 Binary files a/libjava/classpath/lib/java/io/ObjectStreamClass.class and b/libjava/classpath/lib/java/io/ObjectStreamClass.class differ diff --git a/libjava/java/io/ObjectStreamClass.h b/libjava/java/io/ObjectStreamClass.h index 7638f7bed3a..34514534b8d 100644 --- a/libjava/java/io/ObjectStreamClass.h +++ b/libjava/java/io/ObjectStreamClass.h @@ -57,6 +57,9 @@ private: void cacheMethods(); ObjectStreamClass(::java::lang::Class *); void setFlags(::java::lang::Class *); +public: // actually package-private + virtual void ensureFieldsSet(::java::lang::Class *); +private: void setFields(::java::lang::Class *); jlong getClassUID(::java::lang::Class *); public: // actually package-private @@ -105,6 +108,7 @@ private: public: // actually package-private jboolean isProxyClass; private: + jboolean fieldsSet; static const jlong serialVersionUID = -6120832682080437368LL; public: static ::java::lang::Class class$; -- cgit v1.2.1