]> granicus.if.org Git - icu/commitdiff
ICU-11721 small fixes
authorMark Davis <mark@macchiato.com>
Wed, 9 Sep 2015 13:27:10 +0000 (13:27 +0000)
committerMark Davis <mark@macchiato.com>
Wed, 9 Sep 2015 13:27:10 +0000 (13:27 +0000)
X-SVN-Rev: 37919

icu4j/main/tests/framework/src/com/ibm/icu/dev/util/UnicodeMap.java
icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/UnicodeMapTest.java

index 4970fcda7e85e5bf2129fbba9b1b3e7acc7c2ac6..ef48e08d5bca42517e618ecb9a55b1059b2f195b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *******************************************************************************
- * Copyright (C) 1996-2014, International Business Machines Corporation and    *
+ * Copyright (C) 1996-2015, International Business Machines Corporation and    *
  * others. All Rights Reserved.                                                *
  *******************************************************************************
  */
@@ -37,7 +37,7 @@ import com.ibm.icu.util.Freezable;
  * @author markdavis
  */
 
-public final class UnicodeMap<T> implements Cloneable, Freezable, StringTransform, Iterable<String> {
+public final class UnicodeMap<T> implements Cloneable, Freezable<UnicodeMap<T>>, StringTransform, Iterable<String> {
     /**
      * For serialization
      */
@@ -57,7 +57,7 @@ public final class UnicodeMap<T> implements Cloneable, Freezable, StringTransfor
     private transient boolean errorOnReset;
     private volatile transient boolean locked;
     private int lastIndex;
-    private Map<String,T> stringMap;
+    private TreeMap<String,T> stringMap;
 
     { clear(); }
 
@@ -120,6 +120,7 @@ public final class UnicodeMap<T> implements Cloneable, Freezable, StringTransfor
         that.values = (T[]) values.clone();
         that.availableValues = new LinkedHashSet<T>(availableValues);
         that.locked = false;
+        that.stringMap = stringMap == null ? null : (TreeMap<String, T>) stringMap.clone();
         return that;
     }
 
index bb88ebc151c17602a5774f8982d7894dae7655cc..db10dd3cb3c14e0987ebbc888482a4360ee4c733 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *******************************************************************************
- * Copyright (C) 1996-2014, International Business Machines Corporation and    *
+ * Copyright (C) 1996-2015, International Business Machines Corporation and    *
  * others. All Rights Reserved.                                                *
  *******************************************************************************
  */
@@ -285,4 +285,13 @@ public class UnicodeMapTest extends TestFmwk {
         }
         return true;
     }
+    
+    public void TestCloneAsThawed11721 () {
+        UnicodeMap<Integer> test = new UnicodeMap().put("abc", 3).freeze();
+        UnicodeMap<Integer> copy = test.cloneAsThawed();
+        copy.put("def", 4);
+        assertEquals("original-abc", (Integer) 3, test.get("abc"));
+        assertNull("original-def", test.get("def"));
+        assertEquals("copy-def", (Integer) 4, copy.get("def"));
+    }
 }