Index: E:/projects/clear/eclipse/workspace/luni/src/test/java/tests/api/java/util/HashtableTest.java =================================================================== --- E:/projects/clear/eclipse/workspace/luni/src/test/java/tests/api/java/util/HashtableTest.java (revision 389378) +++ E:/projects/clear/eclipse/workspace/luni/src/test/java/tests/api/java/util/HashtableTest.java (working copy) @@ -1,4 +1,4 @@ -/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable +/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import java.util.TreeMap; import java.util.Vector; +import tests.api.java.util.HashMapTest.ReusableKey; import tests.support.Support_MapTest2; import tests.support.Support_UnmodifiableCollectionTest; @@ -275,6 +276,19 @@ Hashtable h = hashtableClone(htfull); assertTrue("Could not retrieve element", ((String) h.get("FKey 2")) .equals("FVal 2")); + + + // Regression for HARMONY-262 + ReusableKey k = new ReusableKey(); + Hashtable h2 = new Hashtable(); + k.setKey(1); + h2.put(k, "value1"); + + k.setKey(13); + assertNull(h2.get(k)); + + k.setKey(12); + assertNull(h2.get(k)); } /** 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 389378) +++ E:/projects/clear/eclipse/workspace/luni/src/test/java/tests/api/java/util/HashMapTest.java (working copy) @@ -1,4 +1,4 @@ -/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable +/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -388,7 +388,7 @@ } - private static class ReusableKey { + static class ReusableKey { private int key = 0; public void setKey(int key) { Index: E:/projects/clear/eclipse/workspace/luni/src/main/java/java/util/Hashtable.java =================================================================== --- E:/projects/clear/eclipse/workspace/luni/src/main/java/java/util/Hashtable.java (revision 389378) +++ E:/projects/clear/eclipse/workspace/luni/src/main/java/java/util/Hashtable.java (working copy) @@ -1,4 +1,4 @@ -/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable +/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,9 +63,12 @@ private static class Entry extends MapEntry { Entry next; + + final int hashcode; Entry(Object theKey, Object theValue) { super(theKey, theValue); + hashcode = theKey.hashCode(); } public Object clone() { @@ -88,7 +91,7 @@ } public boolean equalsKey(Object aKey, int hash) { - return key.equals(aKey); + return hashcode == aKey.hashCode() && key.equals(aKey); } public String toString() {