]> granicus.if.org Git - icu/commitdiff
ICU-8268 impossible cast from double[] to int[].
authorAbhinav Gupta <mail@abhinavg.net>
Tue, 27 Sep 2011 19:49:59 +0000 (19:49 +0000)
committerAbhinav Gupta <mail@abhinavg.net>
Tue, 27 Sep 2011 19:49:59 +0000 (19:49 +0000)
Java doesn't allow casting array of type A to array of type B. The elements
have to be manually casted.

X-SVN-Rev: 30723

icu4j/main/classes/core/src/com/ibm/icu/impl/Utility.java

index df5192aa1b2e565f6c357992550207b9c39e0d4c..a6b72d2c8d03e7bc3a697b423d5d4380ba00f4bf 100644 (file)
@@ -77,8 +77,13 @@ public final class Utility {
             return(arrayEquals((Object[]) source,target));
         if (source instanceof int[])
             return(arrayEquals((int[]) source,target));
-        if (source instanceof double[])
-            return(arrayEquals((int[]) source,target));
+        if (source instanceof double[]) {
+            double[] oldSource = (double[]) source;
+            int[] newSource = new int[oldSource.length];
+            for (int i = 0; i < oldSource.length; i++)
+                newSource[i] = (int)oldSource[i];
+            return arrayEquals(newSource, target);
+        }
         if (source instanceof byte[])
             return(arrayEquals((byte[]) source,target));
         return source.equals(target);