-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
1.4.0
-
sparc
-
solaris_2.6
Name: ooR10001 Date: 09/28/2000
if object constructed by anonymous inner class will be serialized in jdk version before 1.3
then it can not be deserialized in jdk version after 1.3 - this is a compatibility problem.
This is a test which illustrate this bug:
--------
public class test {
public static void main(String[] args) {
if (args.length == 0) {
java.awt.Frame m =
new java.awt.Frame() {
public boolean isResizable() {
return false;
}
};
try {
java.io.FileOutputStream fs =
new java.io.FileOutputStream("test.ser");
java.io.ObjectOutputStream oos =
new java.io.ObjectOutputStream(fs);
oos.writeObject(m);
oos.close();
} catch (java.io.IOException e) {
System.out.println("FAILED:" + e);
}
} else {
Object m = null;
try {
java.io.FileInputStream fs =
new java.io.FileInputStream("test.ser");
java.io.ObjectInputStream ois =
new java.io.ObjectInputStream(fs);
m = ois.readObject();
ois.close();
} catch (java.io.IOException e) {
System.out.println("FAILED:" + e);
} catch (ClassNotFoundException e) {
System.out.println("FAILED:" + e);
}
if (m instanceof java.awt.Frame) {
System.out.println("OKAY");
} else {
System.out.println("FAILED");
}
}
}
}
--------
This test was compiled under jdk 1.2 and executed with no command line parameters for creating
file test.ser.
Corresponded commands are:
-----
javac - d . test.java
java -cplasspath .:$CLASSPATH test
-----
Then it was compiled under jdk version 1.4 and executed with one command line parameters for
deserializing an object from test.ser.
Corresponded commands are:
-----
javac - d . test.java
java -classpath .:$CLASSPATH test tt
-----
Output:
--------
FAILED:java.io.InvalidClassException: test$1; Local class not compatible: stream classdesc
serialVersionUID=6045298662845868053 local class serialVersionUID=7406725469941465764
FAILED
--------
Note: this bug is reproduced only if test is RECOMPILED for each jdk version.
It needs to be fixed.
Jusification:
The following JCK test failure:
api/java_applet/serialization/descriptions.html#Applet
======================================================================