]> granicus.if.org Git - icu/commitdiff
ICU-12812 Fixed some build and test issues introduced by LoicaleMatcher changes ...
authorYoshito Umaoka <y.umaoka@gmail.com>
Mon, 20 Mar 2017 16:09:08 +0000 (16:09 +0000)
committerYoshito Umaoka <y.umaoka@gmail.com>
Mon, 20 Mar 2017 16:09:08 +0000 (16:09 +0000)
X-SVN-Rev: 39883

icu4j/build.xml
icu4j/main/classes/core/src/com/ibm/icu/impl/TextTrieMap.java
icu4j/main/classes/core/src/com/ibm/icu/impl/Utility.java
icu4j/main/classes/core/src/com/ibm/icu/impl/locale/XLikelySubtags.java
icu4j/main/classes/core/src/com/ibm/icu/impl/locale/XLocaleDistance.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatTest.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberRegressionTests.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/number/FormatQuantityTest.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/DataDrivenTestHelper.java

index a604b95d4c29d647c2d53a93dd9d3a84d82248f7..03d10a11f06faa53e03f45183744c406c548c5aa 100644 (file)
         <include name="**/*Test*"/>
         <exclude name="**/*Fmwk*"/>
         <exclude name="**/*TestUtility*"/>
+        <exclude name="**/*TestHelper*"/>
         <exclude name="**/*TestCase*"/>
         <exclude name="**/*TestData*"/>
         <exclude name="**/*TestSample*"/>
index 2576ff18d1c3fa4ffd5ca657d64f0448fd99a038..c7b8d443cdabce1e8896a963a4d46ef8b0fde2a5 100644 (file)
@@ -14,6 +14,7 @@ import java.util.List;
 import java.util.ListIterator;
 
 import com.ibm.icu.lang.UCharacter;
+import com.ibm.icu.text.UTF16;
 
 /**
  * TextTrieMap is a trie implementation for supporting
@@ -118,7 +119,7 @@ public class TextTrieMap<V> {
         startingCp = UCharacter.foldCase(startingCp, true);
       }
       int count = Character.charCount(startingCp);
-      char ch1 = (count == 1) ? (char) startingCp : Character.highSurrogate(startingCp);
+      char ch1 = (count == 1) ? (char) startingCp : UTF16.getLeadSurrogate(startingCp);
       if (!_root.hasChildFor(ch1)) {
         return null;
       }
@@ -152,10 +153,10 @@ public class TextTrieMap<V> {
           cp = UCharacter.foldCase(cp, true);
         }
         int count = Character.charCount(cp);
-        char ch1 = (count == 1) ? (char) cp : Character.highSurrogate(cp);
+        char ch1 = (count == 1) ? (char) cp : UTF16.getLeadSurrogate(cp);
         node.takeStep(ch1, offset, result);
         if (count == 2 && result.node != null) {
-          char ch2 = Character.lowSurrogate(cp);
+          char ch2 = UTF16.getTrailSurrogate(cp);
           result.node.takeStep(ch2, result.offset, result);
         }
         node = result.node;
index c1790a53f06947690f0b82c761fc835e305cf370..061956379f7757ea36e14ac21f3ad599a233a748 100644 (file)
@@ -10,6 +10,7 @@ package com.ibm.icu.impl;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Locale;
 import java.util.regex.Pattern;
 
@@ -1807,4 +1808,44 @@ public final class Utility {
         }
         return buffer.toString();
     }
+
+    /**
+     * This implementation is equivalent to Java 7+ Objects#equals(Object a, Object b)
+     *
+     * @param a an object
+     * @param b an object to be compared with a for equality
+     * @return true if the arguments are equal to each other and false otherwise
+     */
+    public static boolean equals(Object a, Object b) {
+        return (a == b)
+                || (a != null && b != null && a.equals(b));
+    }
+
+    /**
+     * This implementation is equivalent to Java 7+ Objects#hash(Object... values)
+     * @param values the values to be hashed
+     * @return a hash value of the sequence of input values
+     */
+    public static int hash(Object... values) {
+        return Arrays.hashCode(values);
+    }
+
+    /**
+     * This implementation is equivalent to Java 7+ Objects#hashCode(Object o)
+     * @param o an object
+     * @return a hash value of a non-null argument and 0 for null argument
+     */
+    public static int hashCode(Object o) {
+        return o == null ? 0 : o.hashCode();
+    }
+
+    /**
+     * This implementation is equivalent to Java 7+ Objects#toString(Object o)
+     * @param o an object
+     * @return the result of calling toStirng for a non-null argument and "null" for a
+     * null argument
+     */
+    public static String toString(Object o) {
+        return o == null ? "null" : o.toString();
+    }
 }
index 28c406e1a9037b81463205fa3e7a751f306abbb5..5279bcdaaab8ab767ac3aaed797f41fe75ed9845 100644 (file)
@@ -8,12 +8,12 @@ import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Objects;
 import java.util.Set;
 import java.util.TreeMap;
 
 import com.ibm.icu.impl.ICUData;
 import com.ibm.icu.impl.ICUResourceBundle;
+import com.ibm.icu.impl.Utility;
 import com.ibm.icu.impl.locale.XCldrStub.HashMultimap;
 import com.ibm.icu.impl.locale.XCldrStub.Multimap;
 import com.ibm.icu.impl.locale.XCldrStub.Multimaps;
@@ -206,7 +206,7 @@ public class XLikelySubtags {
         }
         @Override
         public int hashCode() {
-            return Objects.hash(language, script, region);
+            return Utility.hash(language, script, region);
         }
     }
 
@@ -483,7 +483,7 @@ public class XLikelySubtags {
             if (value instanceof Map) {
                 show((Map)value, indent+"\t", output);
             } else {
-                output.append("\t" + Objects.toString(value)).append("\n");
+                output.append("\t" + Utility.toString(value)).append("\n");
             }
             first = indent;
         }
index 9e10715f9694bf79a15c1e349f567d4b83e7ea12..6e1c1f138c02fab0b1745395f92274cef48a1fc2 100644 (file)
@@ -14,7 +14,6 @@ import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Objects;
 import java.util.Set;
 import java.util.TreeMap;
 import java.util.TreeSet;
@@ -22,6 +21,7 @@ import java.util.TreeSet;
 import com.ibm.icu.impl.ICUResourceBundle;
 import com.ibm.icu.impl.Row;
 import com.ibm.icu.impl.Row.R4;
+import com.ibm.icu.impl.Utility;
 import com.ibm.icu.impl.locale.XCldrStub.CollectionUtilities;
 import com.ibm.icu.impl.locale.XCldrStub.ImmutableMap;
 import com.ibm.icu.impl.locale.XCldrStub.ImmutableMultimap;
@@ -357,11 +357,11 @@ public class XLocaleDistance {
                 return false;
             }
             StringDistanceNode other = (StringDistanceNode) obj;
-            return distance == other.distance && Objects.equals(distanceTable, other.distanceTable);
+            return distance == other.distance && Utility.equals(distanceTable, other.distanceTable);
         }
         @Override
         public int hashCode() {
-            return distance ^ Objects.hashCode(distanceTable);
+            return distance ^ Utility.hashCode(distanceTable);
         }
 
         StringDistanceNode(int distance) {
index 9c940fafc7fa924e45489e4579e07a942b2bf061..d3f92feb643debf41dde92137c719c9836d81059 100644 (file)
@@ -4903,7 +4903,8 @@ public class NumberFormatTest extends TestFmwk {
                          new CurrencyAmount(2.34, Currency.getInstance("XSU")), result);
             // pass
         } catch (Exception e) {
-            throw new AssertionError("Should have been able to parse XSU", e);
+            //throw new AssertionError("Should have been able to parse XSU", e);
+            throw new AssertionError("Should have been able to parse XSU: " + e.getMessage());
         }
     }
 
index 5a2e63e967fb87380d575207ff2330f2286b68b9..0b03a846b7d72545bc9b4d356ec54b239fc8de54 100644 (file)
@@ -1573,7 +1573,8 @@ public class NumberRegressionTests extends TestFmwk {
                     assertEquals("Localized FAIL on maxInt", df.getMaximumIntegerDigits(), f2.getMaximumIntegerDigits());
 
                 }catch(IllegalArgumentException ex){
-                    throw new AssertionError("For locale " + avail[i], ex);
+                    //throw new AssertionError("For locale " + avail[i], ex);
+                    throw new AssertionError("For locale " + avail[i] + ": " + ex.getMessage());
                 }
 
 
index 9b491ca80ecdc62772597fb08a92d75c44fbd010..31dc279bb80d61d1c270b658ed956aa22318a7ac 100644 (file)
@@ -8,7 +8,7 @@ import java.math.RoundingMode;
 import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.concurrent.ThreadLocalRandom;
+import java.util.Random;
 
 import org.junit.Test;
 
@@ -404,8 +404,9 @@ public class FormatQuantityTest extends TestFmwk {
 
     // Generate random doubles
     String alert = "UNEXPECTED FAILURE: PLEASE REPORT THIS MESSAGE TO THE ICU TEAM: ";
+    Random rnd = new Random();
     for (int i = 0; i < 1000000; i++) {
-      double d = Double.longBitsToDouble(ThreadLocalRandom.current().nextLong());
+      double d = Double.longBitsToDouble(rnd.nextLong());
       if (Double.isNaN(d) || Double.isInfinite(d)) continue;
       checkDoubleBehavior(d, false, alert);
     }
index 308be8c34e73dc7196efe36fd3350a12d6fe3cdb..eaf84eafe323a1cd184b02040da046441fd3f779 100644 (file)
@@ -7,11 +7,11 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-import java.util.Objects;
 
 import com.ibm.icu.dev.test.AbstractTestLog;
 import com.ibm.icu.dev.test.TestFmwk;
 import com.ibm.icu.dev.util.CollectionUtilities;
+import com.ibm.icu.impl.Utility;
 import com.ibm.icu.impl.locale.XCldrStub.FileUtilities;
 import com.ibm.icu.impl.locale.XCldrStub.Splitter;
 import com.ibm.icu.util.ICUUncheckedIOException;
@@ -165,7 +165,7 @@ abstract public class DataDrivenTestHelper {
     }
 
     protected boolean assertEquals(String message, Object expected, Object actual) {
-        return TestFmwk.handleAssert(Objects.equals(expected, actual), message, stringFor(expected), stringFor(actual), null, false);
+        return TestFmwk.handleAssert(Utility.equals(expected, actual), message, stringFor(expected), stringFor(actual), null, false);
     }
 
     private final String stringFor(Object obj) {