Index: E:/projects/clear/eclipse/workspace/luni/src/test/java/tests/api/java/util/HashMapTest.java =================================================================== --- E:/projects/clear/eclipse/workspace/luni/src/test/java/tests/api/java/util/HashMapTest.java (revision 386513) +++ E:/projects/clear/eclipse/workspace/luni/src/test/java/tests/api/java/util/HashMapTest.java (working copy) @@ -375,7 +375,41 @@ !myHashMap.containsValue(new Integer(0))); } + private static class ReusableKey { + private int key = 0; + public void setKey(int key) { + this.key = key; + } + + public int hashCode() { + return key; + } + + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (!(o instanceof ReusableKey)) { + return false; + } + return key == ((ReusableKey) o).key; + } + } + + public void testReusableKey() { + ReusableKey k = new ReusableKey(); + HashMap map = new HashMap(); + k.setKey(1); + map.put(k, "value1"); + + k.setKey(18); + assertNull(map.get(k)); + + k.setKey(17); + assertNull(map.get(k)); + } + /** * Sets up the fixture, for example, open a network connection. This method * is called before a test is executed.