summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPekka Enberg <penberg@kernel.org>2011-02-22 16:10:17 +0000
committerPekka Enberg <penberg@kernel.org>2011-02-22 16:10:17 +0000
commitf154af643a6909a062df3051084da49651d720e6 (patch)
tree9f7f328355b1e8efcfb9b9cc7bbe033ab038fddd
parent91debbc6aae04e6201172303bdb8be952058301a (diff)
downloadclasspath-f154af643a6909a062df3051084da49651d720e6.tar.gz
Fix HashMap.put() to check for hashCode equality before equals()
This patch is needed to run Jython 2.5.2 RC 4 under JamVM and GNU Classpath CVS HEAD. It turns out Jythin bootstrap is bit hairy and assumes HashMap.put() checks for hashCode equality before invoking Object.equals(). 2011-02-22 Pekka Enberg <penberg@kernel.org> * java/util/HashMap: (put): Check for key hashCode equality before invoking Object.equals() to fix compatibility issue with Jython.
-rw-r--r--ChangeLog6
-rw-r--r--java/util/HashMap.java2
2 files changed, 7 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 7eeacf0dd..05aa794b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,12 @@
2011-02-22 Pekka Enberg <penberg@kernel.org>
* java/util/HashMap:
+ (put): Check for key hashCode equality before invoking
+ Object.equals() to fix compatibility issue with Jython.
+
+2011-02-22 Pekka Enberg <penberg@kernel.org>
+
+ * java/util/HashMap:
(DEFAULT_CAPACITY): Make default initial capacity 16 as it is
defined in official Javadocs.
diff --git a/java/util/HashMap.java b/java/util/HashMap.java
index d7a9a7f5b..9d64fecb4 100644
--- a/java/util/HashMap.java
+++ b/java/util/HashMap.java
@@ -345,7 +345,7 @@ public class HashMap<K, V> extends AbstractMap<K, V>
while (e != null)
{
- if (equals(key, e.key))
+ if ((key.hashCode() == e.key.hashCode()) && equals(key, e.key))
{
e.access(); // Must call this for bookkeeping in LinkedHashMap.
V r = e.value;