summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Koch <konqueror@gmx.de>2003-01-10 09:49:50 +0000
committerMichael Koch <konqueror@gmx.de>2003-01-10 09:49:50 +0000
commita36d89b0c46ac6df93ed651bc8ab909f839f2ba4 (patch)
treefc10e7801be802cd14bcf2ea0832b3918071011c
parent02797aea6678a9587a22d6e778836588ebac772c (diff)
downloadclasspath-a36d89b0c46ac6df93ed651bc8ab909f839f2ba4.tar.gz
2003-01-10 Michael Koch <konqueror@gmx.de>
* java/io/ObjectOuputStream.java: Reformated, no code or documentation changes.
-rw-r--r--ChangeLog5
-rw-r--r--java/io/ObjectOutputStream.java459
2 files changed, 232 insertions, 232 deletions
diff --git a/ChangeLog b/ChangeLog
index 397de0dd9..5f0b696a4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2003-01-10 Michael Koch <konqueror@gmx.de>
+
+ * java/io/ObjectOuputStream.java:
+ Reformated, no code or documentation changes.
+
2003-01-05 C. Brian Jones <cbj@gnu.org>
* THANKYOU: fixed Weldon's email reference
diff --git a/java/io/ObjectOutputStream.java b/java/io/ObjectOutputStream.java
index b497e6e88..c1d6c5301 100644
--- a/java/io/ObjectOutputStream.java
+++ b/java/io/ObjectOutputStream.java
@@ -169,245 +169,241 @@ public class ObjectOutputStream extends OutputStream
{
if (useSubclassMethod)
{
- writeObjectOverride (obj);
- return;
+ writeObjectOverride (obj);
+ return;
}
-
+
boolean was_serializing = isSerializing;
-
boolean old_mode = setBlockDataMode (false);
-
try
{
- isSerializing = true;
- boolean replaceDone = false;
-
- Object replacedObject = null;
-
- while (true)
- {
- if (obj == null)
- {
- realOutput.writeByte (TC_NULL);
- break;
- }
-
- Integer handle = findHandle (obj);
- if (handle != null)
- {
- realOutput.writeByte (TC_REFERENCE);
- realOutput.writeInt (handle.intValue ());
- break;
- }
-
- if (obj instanceof Class)
- {
- Class cl = (Class)obj;
- ObjectStreamClass osc = ObjectStreamClass.lookupForClassObject (cl);
- assignNewHandle (obj);
- realOutput.writeByte (TC_CLASS);
- if (!osc.isProxyClass)
- {
- writeObject (osc);
- }
- else
- {
- realOutput.writeByte (TC_PROXYCLASSDESC);
- Class[] intfs = cl.getInterfaces();
- realOutput.writeInt(intfs.length);
- for (int i = 0; i < intfs.length; i++)
- realOutput.writeUTF(intfs[i].getName());
+ isSerializing = true;
+ boolean replaceDone = false;
+ Object replacedObject = null;
+
+ while (true)
+ {
+ if (obj == null)
+ {
+ realOutput.writeByte (TC_NULL);
+ break;
+ }
+
+ Integer handle = findHandle (obj);
+ if (handle != null)
+ {
+ realOutput.writeByte (TC_REFERENCE);
+ realOutput.writeInt (handle.intValue ());
+ break;
+ }
+
+ if (obj instanceof Class)
+ {
+ Class cl = (Class)obj;
+ ObjectStreamClass osc = ObjectStreamClass.lookupForClassObject (cl);
+ assignNewHandle (obj);
+ realOutput.writeByte (TC_CLASS);
+ if (!osc.isProxyClass)
+ {
+ writeObject (osc);
+ }
+ else
+ {
+ realOutput.writeByte (TC_PROXYCLASSDESC);
+ Class[] intfs = cl.getInterfaces();
+ realOutput.writeInt(intfs.length);
+ for (int i = 0; i < intfs.length; i++)
+ realOutput.writeUTF(intfs[i].getName());
- boolean oldmode = setBlockDataMode (true);
- annotateProxyClass(cl);
- setBlockDataMode (oldmode);
- realOutput.writeByte(TC_ENDBLOCKDATA);
+ boolean oldmode = setBlockDataMode (true);
+ annotateProxyClass(cl);
+ setBlockDataMode (oldmode);
+ realOutput.writeByte(TC_ENDBLOCKDATA);
- writeObject (osc.getSuper());
- }
- break;
- }
-
-
- if (obj instanceof ObjectStreamClass)
- {
- ObjectStreamClass osc = (ObjectStreamClass)obj;
- realOutput.writeByte (TC_CLASSDESC);
- realOutput.writeUTF (osc.getName ());
- realOutput.writeLong (osc.getSerialVersionUID ());
- assignNewHandle (obj);
-
- int flags = osc.getFlags ();
-
- if (protocolVersion == PROTOCOL_VERSION_2
- && osc.isExternalizable ())
- flags |= SC_BLOCK_DATA;
-
- realOutput.writeByte (flags);
-
- ObjectStreamField[] fields = osc.fields;
- realOutput.writeShort (fields.length);
-
- ObjectStreamField field;
- for (int i=0; i < fields.length; i++)
- {
- field = fields[i];
- realOutput.writeByte (field.getTypeCode ());
- realOutput.writeUTF (field.getName ());
-
- if (! field.isPrimitive ())
- writeObject (field.getTypeString ());
- }
-
- boolean oldmode = setBlockDataMode (true);
- annotateClass (osc.forClass ());
- setBlockDataMode (oldmode);
- realOutput.writeByte (TC_ENDBLOCKDATA);
-
- if (osc.isSerializable ())
- writeObject (osc.getSuper ());
- else
- writeObject (null);
- break;
- }
-
-
- if ((replacementEnabled || obj instanceof Serializable)
- && ! replaceDone)
- {
- replacedObject = obj;
-
- if (obj instanceof Serializable)
- {
- Method m = null;
- try
- {
- Class classArgs[] = {};
- m = obj.getClass ().getDeclaredMethod ("writeReplace",
- classArgs);
- // m can't be null by definition since an exception would
- // have been thrown so a check for null is not needed.
- obj = m.invoke (obj, new Object[] {});
- }
- catch (NoSuchMethodException ignore)
- {
- }
- catch (IllegalAccessException ignore)
- {
- }
- catch (InvocationTargetException ignore)
- {
- }
- }
-
- if (replacementEnabled)
- obj = replaceObject (obj);
-
- replaceDone = true;
- continue;
- }
-
- if (obj instanceof String)
- {
- realOutput.writeByte (TC_STRING);
- assignNewHandle (obj);
- realOutput.writeUTF ((String)obj);
- break;
- }
-
- Class clazz = obj.getClass ();
- ObjectStreamClass osc = ObjectStreamClass.lookupForClassObject (clazz);
- if (osc == null)
- throw new NotSerializableException (clazz.getName ());
-
- if (clazz.isArray ())
- {
- realOutput.writeByte (TC_ARRAY);
- writeObject (osc);
- assignNewHandle (obj);
- writeArraySizeAndElements (obj, clazz.getComponentType ());
- break;
- }
-
- realOutput.writeByte (TC_OBJECT);
- writeObject (osc);
-
- if (replaceDone)
- assignNewHandle (replacedObject);
- else
- assignNewHandle (obj);
-
- if (obj instanceof Externalizable)
- {
- if (protocolVersion == PROTOCOL_VERSION_2)
- setBlockDataMode (true);
-
- ((Externalizable)obj).writeExternal (this);
-
- if (protocolVersion == PROTOCOL_VERSION_2)
- {
- setBlockDataMode (false);
- realOutput.writeByte (TC_ENDBLOCKDATA);
- }
-
- break;
- }
-
- if (obj instanceof Serializable)
- {
- currentObject = obj;
- ObjectStreamClass[] hierarchy =
- ObjectStreamClass.getObjectStreamClasses (clazz);
-
- boolean has_write;
- for (int i=0; i < hierarchy.length; i++)
- {
- currentObjectStreamClass = hierarchy[i];
-
- fieldsAlreadyWritten = false;
- has_write = currentObjectStreamClass.hasWriteMethod ();
-
- writeFields (obj, currentObjectStreamClass.fields,
- has_write);
-
-// if (has_write)
-// {
-// drain ();
-// realOutput.writeByte (TC_ENDBLOCKDATA);
-// }
- }
-
- currentObject = null;
- currentObjectStreamClass = null;
- currentPutField = null;
- break;
- }
-
- throw new NotSerializableException (clazz.getName ());
- } // end pseudo-loop
+ writeObject (osc.getSuper());
+ }
+ break;
+ }
+
+ if (obj instanceof ObjectStreamClass)
+ {
+ ObjectStreamClass osc = (ObjectStreamClass)obj;
+ realOutput.writeByte (TC_CLASSDESC);
+ realOutput.writeUTF (osc.getName ());
+ realOutput.writeLong (osc.getSerialVersionUID ());
+ assignNewHandle (obj);
+
+ int flags = osc.getFlags ();
+
+ if (protocolVersion == PROTOCOL_VERSION_2
+ && osc.isExternalizable ())
+ flags |= SC_BLOCK_DATA;
+
+ realOutput.writeByte (flags);
+
+ ObjectStreamField[] fields = osc.fields;
+ realOutput.writeShort (fields.length);
+
+ ObjectStreamField field;
+ for (int i=0; i < fields.length; i++)
+ {
+ field = fields[i];
+ realOutput.writeByte (field.getTypeCode ());
+ realOutput.writeUTF (field.getName ());
+
+ if (! field.isPrimitive ())
+ writeObject (field.getTypeString ());
+ }
+
+ boolean oldmode = setBlockDataMode (true);
+ annotateClass (osc.forClass ());
+ setBlockDataMode (oldmode);
+ realOutput.writeByte (TC_ENDBLOCKDATA);
+
+ if (osc.isSerializable ())
+ writeObject (osc.getSuper ());
+ else
+ writeObject (null);
+ break;
+ }
+
+
+ if ((replacementEnabled || obj instanceof Serializable)
+ && ! replaceDone)
+ {
+ replacedObject = obj;
+
+ if (obj instanceof Serializable)
+ {
+ Method m = null;
+ try
+ {
+ Class classArgs[] = {};
+ m = obj.getClass ().getDeclaredMethod ("writeReplace",
+ classArgs);
+ // m can't be null by definition since an exception would
+ // have been thrown so a check for null is not needed.
+ obj = m.invoke (obj, new Object[] {});
+ }
+ catch (NoSuchMethodException ignore)
+ {
+ }
+ catch (IllegalAccessException ignore)
+ {
+ }
+ catch (InvocationTargetException ignore)
+ {
+ }
+ }
+
+ if (replacementEnabled)
+ obj = replaceObject (obj);
+
+ replaceDone = true;
+ continue;
+ }
+
+ if (obj instanceof String)
+ {
+ realOutput.writeByte (TC_STRING);
+ assignNewHandle (obj);
+ realOutput.writeUTF ((String)obj);
+ break;
+ }
+
+ Class clazz = obj.getClass ();
+ ObjectStreamClass osc = ObjectStreamClass.lookupForClassObject (clazz);
+ if (osc == null)
+ throw new NotSerializableException (clazz.getName ());
+
+ if (clazz.isArray ())
+ {
+ realOutput.writeByte (TC_ARRAY);
+ writeObject (osc);
+ assignNewHandle (obj);
+ writeArraySizeAndElements (obj, clazz.getComponentType ());
+ break;
+ }
+
+ realOutput.writeByte (TC_OBJECT);
+ writeObject (osc);
+
+ if (replaceDone)
+ assignNewHandle (replacedObject);
+ else
+ assignNewHandle (obj);
+
+ if (obj instanceof Externalizable)
+ {
+ if (protocolVersion == PROTOCOL_VERSION_2)
+ setBlockDataMode (true);
+
+ ((Externalizable)obj).writeExternal (this);
+
+ if (protocolVersion == PROTOCOL_VERSION_2)
+ {
+ setBlockDataMode (false);
+ realOutput.writeByte (TC_ENDBLOCKDATA);
+ }
+
+ break;
+ }
+
+ if (obj instanceof Serializable)
+ {
+ currentObject = obj;
+ ObjectStreamClass[] hierarchy =
+ ObjectStreamClass.getObjectStreamClasses (clazz);
+
+ boolean has_write;
+ for (int i=0; i < hierarchy.length; i++)
+ {
+ currentObjectStreamClass = hierarchy[i];
+
+ fieldsAlreadyWritten = false;
+ has_write = currentObjectStreamClass.hasWriteMethod ();
+
+ writeFields (obj, currentObjectStreamClass.fields,
+ has_write);
+
+ // if (has_write)
+ // {
+ // drain ();
+ // realOutput.writeByte (TC_ENDBLOCKDATA);
+ // }
+ }
+
+ currentObject = null;
+ currentObjectStreamClass = null;
+ currentPutField = null;
+ break;
+ }
+
+ throw new NotSerializableException (clazz.getName ());
+ } // end pseudo-loop
}
catch (IOException e)
{
- realOutput.writeByte (TC_EXCEPTION);
- reset (true);
-
- setBlockDataMode (false); // ??
- try
- {
- writeObject (e);
- }
- catch (IOException ioe)
- {
- throw new StreamCorruptedException ("Exception " + ioe + " thrown while exception was being written to stream.");
- }
-
- reset (true);
- }
+ realOutput.writeByte (TC_EXCEPTION);
+ reset (true);
+
+ setBlockDataMode (false); // ??
+ try
+ {
+ writeObject (e);
+ }
+ catch (IOException ioe)
+ {
+ throw new StreamCorruptedException ("Exception " + ioe + " thrown while exception was being written to stream.");
+ }
+
+ reset (true);
+ }
finally
{
- isSerializing = was_serializing;
+ isSerializing = was_serializing;
- setBlockDataMode (old_mode);
+ setBlockDataMode (old_mode);
}
}
@@ -545,10 +541,12 @@ public class ObjectOutputStream extends OutputStream
@see java.io.ObjectInputStream#resolveClass (java.io.ObjectStreamClass)
*/
protected void annotateClass (Class cl) throws IOException
- {}
+ {
+ }
protected void annotateProxyClass(Class cl) throws IOException
- {}
+ {
+ }
/**
Allows subclasses to replace objects that are written to the
@@ -647,7 +645,7 @@ public class ObjectOutputStream extends OutputStream
throw new NotActiveException ("Subclass of ObjectOutputStream must implement writeObjectOverride");
}
-
+
/**
@see java.io.DataOutputStream#write (int)
*/
@@ -989,7 +987,6 @@ public class ObjectOutputStream extends OutputStream
= currentObjectStreamClass.getField (name);
if (field == null)
throw new IllegalArgumentException ();
-
if (value != null &&
! field.getType ().isAssignableFrom (value.getClass ()))
throw new IllegalArgumentException ();
@@ -1210,7 +1207,6 @@ public class ObjectOutputStream extends OutputStream
drain();
boolean oldmode = writeDataAsBlocks;
-
writeDataAsBlocks = on;
if (on)
@@ -1265,4 +1261,3 @@ public class ObjectOutputStream extends OutputStream
}
}
}
-