-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
8u192
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=gasp
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
A DESCRIPTION OF THE PROBLEM :
HashMap.putIfAbsent puts elements in undetermined order when executing the following program multiple times:
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the sample program
2. Run it using Oracle HotSpot java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Elements always inserted in the same position.
ACTUAL -
Sometimes HashMap{Object=Object, Object=null}, sometimes HashMap{Object=null, Object=Object}.
---------- BEGIN SOURCE ----------
public class A {
public static void main(String args[]) {
HashMap hm = new HashMap();
hm.putIfAbsent(new Object(), new Object());
hm.putIfAbsent(new Object(), null);
System.out.println(hm.toString());
}
}
---------- END SOURCE ----------
FREQUENCY : always
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=gasp
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
A DESCRIPTION OF THE PROBLEM :
HashMap.putIfAbsent puts elements in undetermined order when executing the following program multiple times:
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the sample program
2. Run it using Oracle HotSpot java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Elements always inserted in the same position.
ACTUAL -
Sometimes HashMap{Object=Object, Object=null}, sometimes HashMap{Object=null, Object=Object}.
---------- BEGIN SOURCE ----------
public class A {
public static void main(String args[]) {
HashMap hm = new HashMap();
hm.putIfAbsent(new Object(), new Object());
hm.putIfAbsent(new Object(), null);
System.out.println(hm.toString());
}
}
---------- END SOURCE ----------
FREQUENCY : always
- duplicates
-
JDK-8227672 HashMap.put() puts elements in random order
- Closed