Fix IndentityHashMap's handling of unboxed keys
...more specifically double and boolean.
PiperOrigin-RevId: 339814745
Change-Id: I6c4222c53adef0a57417d01e047a0372f4ba53ba
diff --git a/user/super/com/google/gwt/emul/java/util/IdentityHashMap.java b/user/super/com/google/gwt/emul/java/util/IdentityHashMap.java
index 1f424a0..0f386b9 100644
--- a/user/super/com/google/gwt/emul/java/util/IdentityHashMap.java
+++ b/user/super/com/google/gwt/emul/java/util/IdentityHashMap.java
@@ -17,8 +17,6 @@
import java.io.Serializable;
-import javaemul.internal.HashCodes;
-
/**
* Map using reference equality on keys. <a
* href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/IdentityHashMap.html">[Sun
@@ -102,6 +100,6 @@
@Override
int getHashCode(Object key) {
- return HashCodes.getObjectIdentityHashCode(key);
+ return System.identityHashCode(key);
}
}
diff --git a/user/test/com/google/gwt/emultest/java/util/IdentityHashMapTest.java b/user/test/com/google/gwt/emultest/java/util/IdentityHashMapTest.java
index 2d1f544..3cf9476 100644
--- a/user/test/com/google/gwt/emultest/java/util/IdentityHashMapTest.java
+++ b/user/test/com/google/gwt/emultest/java/util/IdentityHashMapTest.java
@@ -16,9 +16,6 @@
package com.google.gwt.emultest.java.util;
import com.google.gwt.testing.TestUtils;
-
-import org.apache.commons.collections.TestMap;
-
import java.util.Collection;
import java.util.HashMap;
import java.util.IdentityHashMap;
@@ -27,6 +24,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import org.apache.commons.collections.TestMap;
/**
* Tests <code>IdentityHashMap</code>.
@@ -736,6 +734,16 @@
assertEquals(VALUE_VAL, val);
}
+ public void testUnboxedValues() {
+ IdentityHashMap map = new IdentityHashMap();
+ map.put(true, null);
+ map.put(false, null);
+ map.put(true, null);
+ assertEquals(2, map.size());
+ assertTrue(map.containsKey(true));
+ assertTrue(map.containsKey(false));
+ }
+
@Override
protected Map makeConfirmedMap() {
return new IdentityHashMap();