Index: modules/luni/src/test/api/java/org/apache/harmony/luni/tests/java/util/IdentityHashMapTest.java =================================================================== --- modules/luni/src/test/api/java/org/apache/harmony/luni/tests/java/util/IdentityHashMapTest.java (revision 422694) +++ modules/luni/src/test/api/java/org/apache/harmony/luni/tests/java/util/IdentityHashMapTest.java (working copy) @@ -16,7 +16,7 @@ package org.apache.harmony.luni.tests.java.util; -import java.util.IdentityHashMap; +import java.util.*; import junit.framework.TestCase; @@ -57,4 +57,75 @@ hashMap.remove(null); assertEquals("Assert 3: After removing null element size is incorrect", 0, hashMap.size()); } + + + /** + * @tests java.util.WeakHashMap#WeakHashMap(Map t) + */ + public void test_constructorMinimalMap() { + try { + new IdentityHashMap(new MinimalMap()); + } catch(Throwable e) { + fail("unexpected exception in IdentityHashMap(Map) constructor"); + } + } } + + +class MinimalMap implements Map { + public void clear() { + return; + } + + public boolean containsKey(Object p0) { + return false; + } + + public boolean containsValue(Object p0) { + return false; + } + + public Set entrySet() { + return null; + } + + public boolean equals(Object p0) { + return false; + } + + public Object get(Object p0) { + return null; + } + + public int hashCode() { + return 0; + } + + public boolean isEmpty() { + return false; + } + + public Set keySet() { + return null; + } + + public Object put(Object p0, Object p1) { + return null; + } + + public void putAll(Map p0) { + return; + } + + public Object remove(Object p0) { + return null; + } + + public int size() { + return 0; + } + + public Collection values() { + return null; + } +} Index: modules/luni/src/main/java/java/util/IdentityHashMap.java =================================================================== --- modules/luni/src/main/java/java/util/IdentityHashMap.java (revision 422694) +++ modules/luni/src/main/java/java/util/IdentityHashMap.java (working copy) @@ -281,7 +281,9 @@ */ public IdentityHashMap(Map map) { this(map.size() < 6 ? 11 : map.size() * 2); - putAll(map); + if(map.entrySet() != null) { + putAll(map); + } } @SuppressWarnings("unchecked")