Hi,

On Tue, 2004-11-02 at 19:44, Mattias Rehnberg wrote:
> Guilhem Lavaux <[EMAIL PROTECTED]> wrote:
> > Thanks. Just one question: I don't remember why we should call 
> > defaultWrite/ReadObject in Vector. The logic behind this call is the 
> > same as if there would not be any write/readObject. BTW, these two 
> > patches concerning the core java library have to go to 
> > [EMAIL PROTECTED]   As they are two lined I don't think you'll need 
> > paperwork. ;)
>
> Refering to the document at the URL below, 'classdata' will be writen
> on the form 'wrclass objectAnnotation' if it has a write method
> instead of just 'nowrclass'. Since objectAnnotation is a least an
> endBlockData byte, you'll get that byte when you try to deserialize
> the next object in the stream.
> 
> I found this when I tried to deserialize a stream of two Vectors
> written with Sun's Java, the first one deserialized ok, but the second
> one gave me a null reference.
> 
> http://java.sun.com/j2se/1.4.2/docs/guide/serialization/spec/protocol.html

Thanks for the bug report, fix and for forwarding to GNU Classpath. It
seems correct. And making the write method serialized is a good point
since Vector should be thread-safe. But I don't think we need an
explicit read method since there is no other thread trying to manipulate
the Vector at the same time (since the object stream has the only
reference to it). And luckily we don't need it, if we apply the follow
fix from Andrew which went into libgcj a little while ago:

2004-11-06  Andrew Haley  <[EMAIL PROTECTED]>

        * java/io/ObjectInputStream.java
        (readObject): ENDBLOCKDATA is generated if the class has a write
        method, not if it has a read method.

This makes the mauve test pass even though we removed the readObject()
method. (Without this patch, removing the read method, while a class has
write object, doesn't work correctly). So I have also done that:

2004-11-06  Mark Wielaard  <[EMAIL PROTECTED]>

        * java/util/Vector.java (readObject): Removed.

Committed to GNU Classpath.

Cheers,

Mark
Index: java/io/ObjectInputStream.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/ObjectInputStream.java,v
retrieving revision 1.47
diff -u -r1.47 ObjectInputStream.java
--- java/io/ObjectInputStream.java	11 Oct 2004 13:11:56 -0000	1.47
+++ java/io/ObjectInputStream.java	6 Nov 2004 14:54:56 -0000
@@ -324,6 +324,14 @@
 		      boolean oldmode = setBlockDataMode(true);
 		      callReadMethod(readObjectMethod, this.currentObjectStreamClass.forClass(), obj);
 		      setBlockDataMode(oldmode);
+		    }
+		  else
+		    {
+		      readFields(obj, currentObjectStreamClass);
+		    }
+
+		  if (this.currentObjectStreamClass.hasWriteMethod())
+		    {
 		      if(dump) dumpElement("ENDBLOCKDATA? ");
 		      try
 			{
@@ -346,10 +354,6 @@
 			  if(dump) dumpElementln("no, got IOException");
 			}
 		    }
-		  else
-		    {
-		      readFields(obj, currentObjectStreamClass);
-		    }
 		}
 
 	      this.currentObject = prevObject;
Index: java/util/Vector.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Vector.java,v
retrieving revision 1.21
diff -u -r1.21 Vector.java
--- java/util/Vector.java	3 Nov 2004 17:40:12 -0000	1.21
+++ java/util/Vector.java	6 Nov 2004 14:54:56 -0000
@@ -929,18 +929,4 @@
     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();
-  }
-
 }

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
kaffe mailing list
[EMAIL PROTECTED]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to