-
Bug
-
Resolution: Cannot Reproduce
-
P3
-
None
-
1.4.2
-
sparc
-
solaris_8
Name: ygR10224 Date: 02/20/2003
The number of key-value mappings of java.util.IdentityHashMap
(which returns by size() method) are different before and
after serialization.
See below for an example that reproduces this bug:
-------------------- Test.java ----------------------
import java.util.*;
import java.io.*;
public class Test {
public static void main(String[] args) throws Exception {
IdentityHashMap obj = new IdentityHashMap();
obj.put("dummykey1", "dummyvalue1");
obj.put("dummykey2", "dummyvalue2");
obj.put("dummykey3", "dummyvalue3");
FileOutputStream fos = new FileOutputStream("test.ser");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(obj);
oos.flush();
oos.close();
FileInputStream fis = new FileInputStream("test.ser");
ObjectInputStream ois = new ObjectInputStream(fis);
IdentityHashMap nobj = (IdentityHashMap) ois.readObject();
ois.close();
if (obj.size() == nobj.size()) {
System.out.println("PASSED");
} else {
System.out.println("FAILED");
System.out.println("\"size\" value before and after " +
"serialization not equal (" + obj.size() + " != " +
nobj.size() + ").");
}
}
}
------------------- example output ------------------
java -showversion Test
java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b16)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b16, mixed mode)
FAILED
"size" value before and after serialization not equal (3 != 6).
------------------- end of output -------------------
======================================================================
- relates to
-
JDK-4772121 Unable to marshal java.util.IdentityHashMap
- Closed