-
Bug
-
Resolution: Cannot Reproduce
-
P3
-
None
-
1.2.0
-
sparc
-
solaris_2.5
Name: avC70361 Date: 04/16/98
The java.util.TreeMap and java.util.HashMap classes are incorrectly
deserialized when theirs instances have been serialized on a platform
that differs from one the deserialization is performed on. That is
caused by the incompatibility of local classes on those platforms.
Here is the test demonstrating the bug for java.util.TreeMap.
----------TreeMapTest.java--------
import java.util.*;
import java.io.*;
public class TreeMapTest {
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(new TreeMap());
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);
TreeMap map = (TreeMap)istream.readObject();
System.out.println(args[1] + " is successfuly read");
} catch(Exception e) {
System.out.println("Unexpected exception : " + e);
}
}
}
}
------------The test output------
On Solaris:
<avv@stardust(pts/22).261> java TreeMapTest write file
file is successfuly created
<avv@stardust(pts/22).262> java TreeMapTest read file
file is successfuly read
On Windows:
G:\tmp>java TreeMapTest read file
Unexpected exception : java.io.InvalidClassException: java.util.TreeMap; Local c
lass not compatible: stream classdesc serialVersionUID=6582688042256557735 local
class serialVersionUID=5889614744390323507
NB: We checked out the JavaSoft JDK 1.2-beta3-N version.
It seems that classes java.util.TreeMap put into classes.zip of the
Solaris and Windows versions are different, although files src.zip
contain identical TreeMap.java files. Exactly the same is true for
java.util.HashMap. So it looks like a build problem - please requalify
this bug to the build subcategory if necessary.
======================================================================