-
Bug
-
Resolution: Fixed
-
P3
-
1.2.0
-
1.2beta4
-
sparc
-
solaris_2.5
-
Verified
Name: avC70361 Date: 05/18/98
The java.awt.BorderLayout is incorrectly deserialized in
jdk1.2-beta4 when have been serialized in jdk1.1.6. The exception
java.io.InvalidClassException is thrown
Here is the test demonstarating the bug.
--------------BorderLayoutTest.java--------
import java.io.*;
import java.awt.BorderLayout;
public class BorderLaypoutTest {
public static void main(String args[]) {
BorderLayout layout = new BorderLayout(5, 5);
if (args[0].equals("write")) {
ObjectOutputStream stream = null;
try {
stream = new ObjectOutputStream(new FileOutputStream(args[1]));
stream.writeObject(layout);
stream.close();
} catch(IOException e) {
System.out.println("Couldn't write to " + args[1] + " : " + e);
System.exit(1);
}
System.out.println(args[1] + " written successfully");
} else if (args[0].equals("read")) {
ObjectInputStream stream = null;
try {
stream = new ObjectInputStream(new FileInputStream(args[1]));
layout = (BorderLayout)stream.readObject();
} catch(InvalidClassException e) {
System.out.println("Failed:" + e);
System.exit(1);
} catch(Exception e) {
System.out.println(
"Failed: couldn't read from" + args[1] + " : " + e
);
System.exit(1);
}
System.out.println("Passed");
}
System.exit(0);
}
}
-------------The test output-----------
Under jdk1.1.6:
<avv@stardust(pts/13).467> java -fullversion
java full version "JDK1.1.6N"
You have mail in /var/mail/avv
<avv@stardust(pts/13).468> java BorderLaypoutTest write file.ser
file.ser written successfully
<avv@stardust(pts/13).469> java BorderLaypoutTest read file.ser
Passed
Under jdk1.2beta4:
<avv@stardust(pts/2).660> java -fullversion
java full version "JDK-1.2beta4-F"
You have mail in /var/mail/avv
<avv@stardust(pts/2).661> java BorderLaypoutTest read file.ser
Failed:java.io.InvalidClassException: java.awt.BorderLayout; Local class not compatible: stream classdesc serialVersionUID=-8658291919501921765 local class serialVersionUID=-2863819608532257785
======================================================================