-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.4.2
-
x86
-
windows_xp
Name: gm110360 Date: 02/27/2004
FULL PRODUCT VERSION :
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP
A DESCRIPTION OF THE PROBLEM :
The internal hash function in IdentityHashMap only returns even numbers. Only 1/2 of the internal table is actually used.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should return a fairly even distribution for the table.
ACTUAL -
All hash results were even.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public static void main(String[] args) {
for (; ; ) {
System.out.println(hash(new Object(), 64));
}
}
private static int hash(Object x, int length) {
int h = System.identityHashCode(x);
// Multiply by -127, and left-shift to use least bit as part of hash
return ((h << 1) - (h << 8)) & (length - 1);
}
---------- END SOURCE ----------
(Incident Review ID: 240630)
======================================================================
- relates to
-
JDK-8208713 Java API documentation incorrect in IdentityHashMap
- Closed