diff options
author | Tom Tromey <tromey@redhat.com> | 2007-07-24 15:26:35 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2007-07-24 15:26:35 +0000 |
commit | 62b7f07c6c3ccd698a9c2c7ed9fa39b0ab8edf69 (patch) | |
tree | 644d132212e25b681e1779c78089dc3fa7281b6a | |
parent | 193863c244000ba0c10f0e63d558ffe76fab5d82 (diff) | |
download | classpath-libgcj-import-20070727.tar.gz |
PR java/32862:libgcj-import-20070727
* java/util/EnumMap.java (get): Special case emptySlot.
(clone): Rewrote.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | java/util/EnumMap.java | 19 |
2 files changed, 21 insertions, 4 deletions
@@ -1,3 +1,9 @@ +2007-07-24 Tom Tromey <tromey@redhat.com> + + PR java/32862: + * java/util/EnumMap.java (get): Special case emptySlot. + (clone): Rewrote. + 2007-07-23 Christian Thalinger <twisti@complang.tuwien.ac.at> * gnu/java/nio/charset/ISO_8859_1.java: Added ISO8859-1 to diff --git a/java/util/EnumMap.java b/java/util/EnumMap.java index 477dff8e0..f4286bd10 100644 --- a/java/util/EnumMap.java +++ b/java/util/EnumMap.java @@ -1,5 +1,5 @@ /* EnumMap.java - Map where keys are enum constants - Copyright (C) 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -140,7 +140,8 @@ public class EnumMap<K extends Enum<K>, V> Enum<K> e = (Enum<K>) key; if (e.getDeclaringClass() != enumClass) return null; - return store[e.ordinal()]; + V o = store[e.ordinal()]; + return o == emptySlot ? null : o; } public V put(K key, V value) @@ -387,8 +388,18 @@ public class EnumMap<K extends Enum<K>, V> public EnumMap<K, V> clone() { - /* This constructor provides this functionality */ - return new EnumMap(this); + EnumMap<K, V> result; + try + { + result = (EnumMap<K, V>) super.clone(); + } + catch (CloneNotSupportedException ignore) + { + // Can't happen. + result = null; + } + result.store = store.clone(); + return result; } } |