summaryrefslogtreecommitdiff
path: root/java/io/ObjectOutputStream.java
diff options
context:
space:
mode:
authorWarren Levy <warrenl@redhat.com>2000-08-04 00:45:13 +0000
committerWarren Levy <warrenl@redhat.com>2000-08-04 00:45:13 +0000
commita25f6e61c37f57fd47ff5d99627a42a78642100c (patch)
tree4777e9a27297ccf630c9134fa8f957be38b4ad22 /java/io/ObjectOutputStream.java
parent58dc0f222adcaabf051b3c43435fdaa0fdeb0379 (diff)
downloadclasspath-a25f6e61c37f57fd47ff5d99627a42a78642100c.tar.gz
* ObjectInputStream.java (readFields): Turn off
readDataFromBlock while reading via GetField. (GetField$1.get(String, Object)): Pass Class of default value to getField. (getField): Allow for null default values. * ObjectOutputStream.java: Fixed typo in comment. (PutField$1.put): Fixed calls of checkType in most of the put methods to pass the correct parameter. (PutField$1.put(String, Object)): Allow for null value arg. (PutField$1.write): Turn off writeDataAsBlocks while writing via PutField. * ObjectStreamClass.java (serialPersistentFields): Fixed typo in spec'ed field name. (getSerialPersistentFields): Changed spelling of method to match the correct spelling of the spec'ed field name. More serialization fixes per Mauve results.
Diffstat (limited to 'java/io/ObjectOutputStream.java')
-rw-r--r--java/io/ObjectOutputStream.java22
1 files changed, 14 insertions, 8 deletions
diff --git a/java/io/ObjectOutputStream.java b/java/io/ObjectOutputStream.java
index d688c9b6a..2a03a01e1 100644
--- a/java/io/ObjectOutputStream.java
+++ b/java/io/ObjectOutputStream.java
@@ -136,7 +136,7 @@ public class ObjectOutputStream extends OutputStream
output stream by writing out information about its class, then
writing out each of the objects non-transient, non-static
fields. If any of these fields are other objects,
- the are written out in the same manner.
+ they are written out in the same manner.
This method can be overriden by a class by implementing
<code>private void writeObject (ObjectOutputStream)</code>.
@@ -844,7 +844,7 @@ public class ObjectOutputStream extends OutputStream
{
ObjectStreamField field
= currentObjectStreamClass.getField (name);
- checkType (field, 'B');
+ checkType (field, 'C');
int off = field.getOffset ();
prim_field_data[off++] = (byte)(value >>> 8);
prim_field_data[off] = (byte)value;
@@ -855,7 +855,7 @@ public class ObjectOutputStream extends OutputStream
{
ObjectStreamField field
= currentObjectStreamClass.getField (name);
- checkType (field, 'B');
+ checkType (field, 'D');
int off = field.getOffset ();
long l_value = Double.doubleToLongBits (value);
prim_field_data[off++] = (byte)(l_value >>> 52);
@@ -873,7 +873,7 @@ public class ObjectOutputStream extends OutputStream
{
ObjectStreamField field
= currentObjectStreamClass.getField (name);
- checkType (field, 'B');
+ checkType (field, 'F');
int off = field.getOffset ();
int i_value = Float.floatToIntBits (value);
prim_field_data[off++] = (byte)(i_value >>> 24);
@@ -887,7 +887,7 @@ public class ObjectOutputStream extends OutputStream
{
ObjectStreamField field
= currentObjectStreamClass.getField (name);
- checkType (field, 'B');
+ checkType (field, 'I');
int off = field.getOffset ();
prim_field_data[off++] = (byte)(value >>> 24);
prim_field_data[off++] = (byte)(value >>> 16);
@@ -900,7 +900,7 @@ public class ObjectOutputStream extends OutputStream
{
ObjectStreamField field
= currentObjectStreamClass.getField (name);
- checkType (field, 'B');
+ checkType (field, 'J');
int off = field.getOffset ();
prim_field_data[off++] = (byte)(value >>> 52);
prim_field_data[off++] = (byte)(value >>> 48);
@@ -917,7 +917,7 @@ public class ObjectOutputStream extends OutputStream
{
ObjectStreamField field
= currentObjectStreamClass.getField (name);
- checkType (field, 'B');
+ checkType (field, 'S');
int off = field.getOffset ();
prim_field_data[off++] = (byte)(value >>> 8);
prim_field_data[off] = (byte)value;
@@ -928,16 +928,22 @@ public class ObjectOutputStream extends OutputStream
{
ObjectStreamField field
= currentObjectStreamClass.getField (name);
- if (! field.getType ().isAssignableFrom (value.getClass ()))
+ if (value != null &&
+ ! field.getType ().isAssignableFrom (value.getClass ()))
throw new IllegalArgumentException ();
objs[field.getOffset ()] = value;
}
public void write (ObjectOutput out) throws IOException
{
+ // Apparently Block data is not used with PutField as per
+ // empirical evidence against JDK 1.2. Also see Mauve test
+ // java.io.ObjectInputOutput.Test.GetPutField.
+ setBlockDataMode (false);
out.write (prim_field_data);
for (int i = 0; i < objs.length; ++ i)
out.writeObject (objs[i]);
+ setBlockDataMode (true);
}
private void checkType (ObjectStreamField field, char type)