You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2006/03/28 11:30:23 UTC
svn commit: r389451 - in
/incubator/harmony/enhanced/classlib/trunk/modules/luni/src:
main/java/java/util/Hashtable.java
test/java/tests/api/java/util/HashMapTest.java
test/java/tests/api/java/util/HashtableTest.java
Author: tellison
Date: Tue Mar 28 01:30:02 2006
New Revision: 389451
URL: http://svn.apache.org/viewcvs?rev=389451&view=rev
Log:
Fix for HARMONY-262 (java.util.Hashtable, same as HashMap, has similar non-compatible behavior with RI)
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Hashtable.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashMapTest.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashtableTest.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Hashtable.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Hashtable.java?rev=389451&r1=389450&r2=389451&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Hashtable.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Hashtable.java Tue Mar 28 01:30:02 2006
@@ -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() {
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashMapTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashMapTest.java?rev=389451&r1=389450&r2=389451&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashMapTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashMapTest.java Tue Mar 28 01:30:02 2006
@@ -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) {
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashtableTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashtableTest.java?rev=389451&r1=389450&r2=389451&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashtableTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashtableTest.java Tue Mar 28 01:30:02 2006
@@ -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));
}
/**