[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] Small fixes for serialization
From: |
Guilhem Lavaux |
Subject: |
[cp-patches] Small fixes for serialization |
Date: |
Tue, 02 Nov 2004 21:30:38 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040115 |
Hi,
Here are two fixes for serialization as reported/fixed by Mattias
Rehnberg <address@hidden>.
I've added a mauve test for the Vector problem.
2004-11-02 Mattias Rehnberg <address@hidden>
* java/io/Vector.java
(readObject, writeObject): New function to match Sun's
serialized output for Vector.
* java/io/ObjectOutputStream.java
(writeObject): Move the assignment of the class handle to after
the assignment of class descriptor handle.
Index: java/util/Vector.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Vector.java,v
retrieving revision 1.20
diff -u -r1.20 Vector.java
--- java/util/Vector.java 22 Apr 2004 11:24:39 -0000 1.20
+++ java/util/Vector.java 2 Nov 2004 20:31:06 -0000
@@ -37,6 +37,9 @@
package java.util;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.lang.reflect.Array;
@@ -912,4 +915,32 @@
if (index >= elementCount)
throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount);
}
+
+ /**
+ * Serializes this object to the given stream.
+ *
+ * @param s the stream to write to
+ * @throws IOException if the underlying stream fails
+ * @serialData just calls default write function
+ */
+ private synchronized void writeObject(ObjectOutputStream s)
+ throws IOException
+ {
+ s.defaultWriteObject();
+ }
+
+ /**
+ * Deserializes this object from the given stream.
+ *
+ * @param s the stream to read from
+ * @throws ClassNotFoundException if the underlying stream fails
+ * @throws IOException if the underlying stream fails
+ * @serialData just calls default read function
+ */
+ private void readObject(ObjectInputStream s)
+ throws IOException, ClassNotFoundException
+ {
+ s.defaultReadObject();
+ }
+
}
Index: java/io/ObjectOutputStream.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/ObjectOutputStream.java,v
retrieving revision 1.49
diff -u -r1.49 ObjectOutputStream.java
--- java/io/ObjectOutputStream.java 11 Oct 2004 09:45:20 -0000 1.49
+++ java/io/ObjectOutputStream.java 2 Nov 2004 20:31:06 -0000
@@ -220,7 +220,6 @@
{
Class cl = (Class)obj;
ObjectStreamClass osc =
ObjectStreamClass.lookupForClassObject(cl);
- assignNewHandle(obj);
realOutput.writeByte(TC_CLASS);
if (!osc.isProxyClass)
{
@@ -241,6 +240,7 @@
writeObject(osc.getSuper());
}
+ assignNewHandle(obj);
break;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] Small fixes for serialization,
Guilhem Lavaux <=