-
Bug
-
Resolution: Fixed
-
P3
-
1.2.2
-
1.2.2
-
sparc
-
solaris_2.5
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2024957 | 1.3.0 | Josh Bloch | P3 | Resolved | Fixed | kestrel |
Name: avC70361 Date: 02/03/99
The java.util.Arrays$ArrayList fails to be deserialized in jdk 1.2.2 when
the serialization has been performed in earlier version of jdk(jdk 1.2)
because its serialVersionUID is not the same in different jdk versions.
Here is a test demonstrating the bug.
---------ArraysArrayListTest.java--------
import java.util.*;
import java.io.*;
public class ArraysArrayListTest {
public static void main(String args[]) {
if (args[0].equals("write")) {
try {
FileOutputStream fos = new FileOutputStream(args[1]);
ObjectOutputStream ostream = new ObjectOutputStream(fos);
ostream.writeObject(Arrays.asList(new Object[] {""}));
ostream.flush();
fos.close();
System.out.println(args[1] + " is successfuly created");
} catch(IOException e) {
System.out.println("Unexpected exception : " + e);
}
} else if (args[0].equals("read")) {
try {
FileInputStream fis = new FileInputStream(args[1]);
ObjectInputStream istream = new ObjectInputStream(fis);
List list = (List)istream.readObject();
System.out.println(args[1] + " is successfuly read");
} catch(Exception e) {
System.out.println("Unexpected exception : " + e);
}
}
}
}
---------------The test output--------------
jdk 1.2:
<avv@viking(pts/0).295> java -version
java version "1.2"
Classic VM (build JDK-1.2-V, green threads, sunwjit)
<avv@viking(pts/0).296> java ArraysArrayListTest write file.ser
file.ser is successfuly created
<avv@viking(pts/0).297> java ArraysArrayListTest read file.ser
file.ser is successfuly read
jdk 1.2.2:
<avv@viking(pts/0).299> java -version
java version "1.2.2"
Classic VM (build JDK-1.2.2-D, green threads, sunwjit)
<avv@viking(pts/0).300> java ArraysArrayListTest read file.ser
Unexpected exception : java.io.InvalidClassException: java.util.Arrays$ArrayList; Local class not compatible: stream classdesc serialVersionUID=-2764017481108945198 local class serialVersionUID=6713627758412895285
======================================================================
- backported by
-
JDK-2024957 java.util.Arrays$ArrayList serialization is incompatible between jdk 1.2 and jdk
- Resolved