Commit 692fb023 by Guilhem Lavaux Committed by Michael Koch

2003-12-23 Guilhem Lavaux <guilhem@kaffe.org>

	* java/io/ObjectInputStream.java
	(getField): Handle transient and non persistent fields.
	(readClassDescriptor): Better error handling, use the right
	class loader.
	(readFields): Fields marked as not present in the stream
	or not to be set are not read and set.
	* java/io/ObjectInputStream.java
	(readFields): Changed implementation of GetField.
	(readClassDescriptor): Documented.
	* java/io/ObjectOutputStream.java
	(writeClassDescriptor): Added condition when to write class super
	class information.

From-SVN: r74985
parent f2073745
2003-12-23 Guilhem Lavaux <guilhem@kaffe.org>
* java/io/ObjectInputStream.java
(getField): Handle transient and non persistent fields.
(readClassDescriptor): Better error handling, use the right
class loader.
(readFields): Fields marked as not present in the stream
or not to be set are not read and set.
* java/io/ObjectInputStream.java
(readFields): Changed implementation of GetField.
(readClassDescriptor): Documented.
* java/io/ObjectOutputStream.java
(writeClassDescriptor): Added condition when to write class super
class information.
2003-12-22 Fernando Nasser <fnasser@redhat.com> 2003-12-22 Fernando Nasser <fnasser@redhat.com>
* gnu/java/awt/peer/gtk/GtkChoicePeer.java (postItemEvent): Rename to... * gnu/java/awt/peer/gtk/GtkChoicePeer.java (postItemEvent): Rename to...
......
...@@ -407,7 +407,8 @@ public class ObjectOutputStream extends OutputStream ...@@ -407,7 +407,8 @@ public class ObjectOutputStream extends OutputStream
setBlockDataMode (oldmode); setBlockDataMode (oldmode);
realOutput.writeByte (TC_ENDBLOCKDATA); realOutput.writeByte (TC_ENDBLOCKDATA);
if (osc.isSerializable ()) if (osc.isSerializable()
|| osc.isExternalizable())
writeObject (osc.getSuper ()); writeObject (osc.getSuper ());
else else
writeObject (null); writeObject (null);
......
...@@ -516,9 +516,12 @@ public class ObjectStreamClass implements Serializable ...@@ -516,9 +516,12 @@ public class ObjectStreamClass implements Serializable
&& Modifier.isPrivate (modifiers)) && Modifier.isPrivate (modifiers))
{ {
fields = getSerialPersistentFields (cl); fields = getSerialPersistentFields (cl);
Arrays.sort (fields); if (fields != null)
calculateOffsets (); {
return; Arrays.sort(fields);
calculateOffsets();
return;
}
} }
} }
catch (NoSuchFieldException ignore) catch (NoSuchFieldException ignore)
...@@ -700,16 +703,41 @@ public class ObjectStreamClass implements Serializable ...@@ -700,16 +703,41 @@ public class ObjectStreamClass implements Serializable
} }
} }
// Returns the value of CLAZZ's private static final field named /**
// `serialPersistentFields'. * Returns the value of CLAZZ's private static final field named
* `serialPersistentFields'. It performs some sanity checks before
* returning the real array. Besides, the returned array is a clean
* copy of the original. So it can be modified.
*
* @param clazz Class to retrieve 'serialPersistentFields' from.
* @return The content of 'serialPersistentFields'.
*/
private ObjectStreamField[] getSerialPersistentFields (Class clazz) private ObjectStreamField[] getSerialPersistentFields (Class clazz)
throws NoSuchFieldException, IllegalAccessException throws NoSuchFieldException, IllegalAccessException
{ {
ObjectStreamField[] fieldsArray = null;
ObjectStreamField[] o;
// Use getDeclaredField rather than getField for the same reason // Use getDeclaredField rather than getField for the same reason
// as above in getDefinedSUID. // as above in getDefinedSUID.
Field f = clazz.getDeclaredField("serialPersistentFields"); Field f = clazz.getDeclaredField("serialPersistentFields");
f.setAccessible(true); f.setAccessible(true);
return (ObjectStreamField[]) f.get(null);
int modifiers = f.getModifiers();
if (!(Modifier.isStatic(modifiers)
&& Modifier.isFinal(modifiers)
&& Modifier.isPrivate(modifiers)))
return null;
o = (ObjectStreamField[]) f.get(null);
if (o == null)
return null;
fieldsArray = new ObjectStreamField[o.length];
System.arraycopy(o, 0, fieldsArray, 0, o.length);
return fieldsArray;
} }
public static final ObjectStreamField[] NO_FIELDS = {}; public static final ObjectStreamField[] NO_FIELDS = {};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment