diff options
Diffstat (limited to 'libjava/classpath/java/util')
-rw-r--r-- | libjava/classpath/java/util/Arrays.java | 3 | ||||
-rw-r--r-- | libjava/classpath/java/util/Currency.java | 5 | ||||
-rw-r--r-- | libjava/classpath/java/util/EnumMap.java | 19 |
3 files changed, 22 insertions, 5 deletions
diff --git a/libjava/classpath/java/util/Arrays.java b/libjava/classpath/java/util/Arrays.java index 9443ced5bdd..e5f772778c2 100644 --- a/libjava/classpath/java/util/Arrays.java +++ b/libjava/classpath/java/util/Arrays.java @@ -3941,7 +3941,8 @@ public class Arrays if (from > to) throw new IllegalArgumentException("The initial index is after " + "the final index."); - T[] newArray = (T[]) new Object[to - from]; + Class elemType = original.getClass().getComponentType(); + T[] newArray = (T[]) Array.newInstance(elemType, to - from); if (to > original.length) { System.arraycopy(original, from, newArray, 0, diff --git a/libjava/classpath/java/util/Currency.java b/libjava/classpath/java/util/Currency.java index a0933eca2f6..b5da13c37f1 100644 --- a/libjava/classpath/java/util/Currency.java +++ b/libjava/classpath/java/util/Currency.java @@ -273,6 +273,11 @@ public final class Currency throw new NullPointerException("The locale or its country is null."); } + + /* Check that country of locale given is valid. */ + if (country.length() != 2) + throw new IllegalArgumentException(); + /* Attempt to get the currency from the cache */ String code = (String) countryMap.get(country); if (code == null) diff --git a/libjava/classpath/java/util/EnumMap.java b/libjava/classpath/java/util/EnumMap.java index 477dff8e0ab..b7187b935f2 100644 --- a/libjava/classpath/java/util/EnumMap.java +++ b/libjava/classpath/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 = (V[]) store.clone(); + return result; } } |