Relates :
|
|
Relates :
|
|
Relates :
|
FULL PRODUCT VERSION : compiled on windows with java version "1.5.0" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64) Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing) or java version "1.4.2" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28) Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode) run on Windows with java version "1.5.0" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64) Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing) run on linux with java version "1.5.0" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64) Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing) ADDITIONAL OS VERSION INFORMATION : Windows 2000 SP4 (Microsoft Windows 2000 [Version 5.00.2195]), Linux (Linux 2.6.4 #1 SMP i686 GNU/Linux) A DESCRIPTION OF THE PROBLEM : When creating a new ArrayList passing it a result of entrySet() called on IdentityHashMap of size one, the resulting ArrayList is of size one but contains null instead of a reference to object the original IdentityHashMap contains. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Compile and run the sample testcase provided. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - ls: [com.parsek.test.BugTest$KeyClass@35ce36=com.parsek.test.BugTest$ValueClass@1a46e30] ls2: [com.parsek.test.BugTest$KeyClass@35ce36=com.parsek.test.BugTest$ValueClass@1a46e30] ACTUAL - ls: [null] ls2: [com.parsek.test.BugTest$KeyClass@35ce36=com.parsek.test.BugTest$ValueClass@1a46e30] REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.util.*; public class BugTest { static class KeyClass { String somefield; } static class ValueClass { String somevalue; } public static void main(String [] args) throws Exception { IdentityHashMap map = new IdentityHashMap(); map.put(new KeyClass(), new ValueClass()); ArrayList ls = new ArrayList(map.entrySet()); System.out.println("ls: " + ls); LinkedList ls2 = new LinkedList(map.entrySet()); System.out.println("ls2: " + ls2); } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : Use LinkedList or HashSet instead of ArrayList ###@###.### 2005-2-24 02:21:22 GMT
|