ART: Fix System.arraycopy

We cannot use the same code for float+int and long+double. In debug
mode, this will fail.

Change-Id: Icf263626896a7b53e59685c474e77b4c3128ecd5
diff --git a/runtime/native/java_lang_System.cc b/runtime/native/java_lang_System.cc
index 736b42b..97aae67 100644
--- a/runtime/native/java_lang_System.cc
+++ b/runtime/native/java_lang_System.cc
@@ -105,15 +105,21 @@
         dstArray->AsShortSizedArray()->Memmove(dstPos, srcArray->AsShortSizedArray(), srcPos, count);
         return;
       case Primitive::kPrimInt:
-      case Primitive::kPrimFloat:
         DCHECK_EQ(Primitive::ComponentSize(dstComponentPrimitiveType), 4U);
         dstArray->AsIntArray()->Memmove(dstPos, srcArray->AsIntArray(), srcPos, count);
         return;
+      case Primitive::kPrimFloat:
+        DCHECK_EQ(Primitive::ComponentSize(dstComponentPrimitiveType), 4U);
+        dstArray->AsFloatArray()->Memmove(dstPos, srcArray->AsFloatArray(), srcPos, count);
+        return;
       case Primitive::kPrimLong:
-      case Primitive::kPrimDouble:
         DCHECK_EQ(Primitive::ComponentSize(dstComponentPrimitiveType), 8U);
         dstArray->AsLongArray()->Memmove(dstPos, srcArray->AsLongArray(), srcPos, count);
         return;
+      case Primitive::kPrimDouble:
+        DCHECK_EQ(Primitive::ComponentSize(dstComponentPrimitiveType), 8U);
+        dstArray->AsDoubleArray()->Memmove(dstPos, srcArray->AsDoubleArray(), srcPos, count);
+        return;
       case Primitive::kPrimNot: {
         mirror::ObjectArray<mirror::Object>* dstObjArray = dstArray->AsObjectArray<mirror::Object>();
         mirror::ObjectArray<mirror::Object>* srcObjArray = srcArray->AsObjectArray<mirror::Object>();
diff --git a/test/011-array-copy/src/Main.java b/test/011-array-copy/src/Main.java
index 505d8b0..96e1dbf 100644
--- a/test/011-array-copy/src/Main.java
+++ b/test/011-array-copy/src/Main.java
@@ -23,6 +23,7 @@
     public static void main(String args[]) {
         testObjectCopy();
         testOverlappingMoves();
+        testFloatAndDouble();
     }
 
     public static void testObjectCopy() {
@@ -143,4 +144,13 @@
         /* copy forward, mixed alignment, trivial length */
         makeCopies(0, 5, 1);
     }
+
+    private static void testFloatAndDouble() {
+        // Float & double copies have the same implementation as int & long. However, there are
+        // protective DCHECKs in the code (there is nothing unifying like ByteSizedArray or
+        // ShortSizedArray). Just test that we don't fail those checks.
+        final int len = 10;
+        System.arraycopy(new float[len], 0, new float[len], 0, len);
+        System.arraycopy(new double[len], 0, new double[len], 0, len);
+    }
 }