Merge "Extract more reference inits." into dalvik-dev
diff --git a/vm/Globals.h b/vm/Globals.h
index 07661af..28cd173 100644
--- a/vm/Globals.h
+++ b/vm/Globals.h
@@ -399,7 +399,7 @@
     int         offJavaNioBuffer_effectiveDirectAddress;
 
     /*
-     * VM-synthesized primitive classes, for arrays.
+     * VM-synthesized primitive classes, for arrays and reflection
      */
     ClassObject* volatile primitiveClass[PRIM_MAX];
 
diff --git a/vm/InitRefs.c b/vm/InitRefs.c
index beca536..211ecc4 100644
--- a/vm/InitRefs.c
+++ b/vm/InitRefs.c
@@ -73,6 +73,17 @@
     ok &= initRef(&gDvm.classJavaLangThreadGroup, "Ljava/lang/ThreadGroup;");
     ok &= initRef(&gDvm.classJavaLangVMThread, "Ljava/lang/VMThread;");
 
+    /* Arrays of primitive types */
+
+    ok &= initRef(&gDvm.classArrayBoolean, "[Z");
+    ok &= initRef(&gDvm.classArrayByte, "[B");
+    ok &= initRef(&gDvm.classArrayShort, "[S");
+    ok &= initRef(&gDvm.classArrayChar, "[C");
+    ok &= initRef(&gDvm.classArrayInt, "[I");
+    ok &= initRef(&gDvm.classArrayLong, "[J");
+    ok &= initRef(&gDvm.classArrayFloat, "[F");
+    ok &= initRef(&gDvm.classArrayDouble, "[D");
+
     /* Exception classes and related support classes */
 
     ok &= initRef(&gDvm.exAbstractMethodError,
diff --git a/vm/oo/Array.c b/vm/oo/Array.c
index 33b0f97..99630ca 100644
--- a/vm/oo/Array.c
+++ b/vm/oo/Array.c
@@ -140,67 +140,53 @@
  * Create a new array that holds primitive types.
  *
  * "type" is the primitive type letter, e.g. 'I' for int or 'J' for long.
- * If the array class doesn't exist, it will be created.
  */
 ArrayObject* dvmAllocPrimitiveArray(char type, size_t length, int allocFlags)
 {
     ArrayObject* newArray;
-    ClassObject** pTypeClass;
+    ClassObject* arrayClass;
     int width;
 
     switch (type) {
     case 'I':
-        pTypeClass = &gDvm.classArrayInt;
+        arrayClass = gDvm.classArrayInt;
         width = 4;
         break;
     case 'C':
-        pTypeClass = &gDvm.classArrayChar;
+        arrayClass = gDvm.classArrayChar;
         width = 2;
         break;
     case 'B':
-        pTypeClass = &gDvm.classArrayByte;
+        arrayClass = gDvm.classArrayByte;
         width = 1;
         break;
     case 'Z':
-        pTypeClass = &gDvm.classArrayBoolean;
+        arrayClass = gDvm.classArrayBoolean;
         width = 1; /* special-case this? */
         break;
     case 'F':
-        pTypeClass = &gDvm.classArrayFloat;
+        arrayClass = gDvm.classArrayFloat;
         width = 4;
         break;
     case 'D':
-        pTypeClass = &gDvm.classArrayDouble;
+        arrayClass = gDvm.classArrayDouble;
         width = 8;
         break;
     case 'S':
-        pTypeClass = &gDvm.classArrayShort;
+        arrayClass = gDvm.classArrayShort;
         width = 2;
         break;
     case 'J':
-        pTypeClass = &gDvm.classArrayLong;
+        arrayClass = gDvm.classArrayLong;
         width = 8;
         break;
     default:
-        LOGE("Unknown type '%c'\n", type);
-        assert(false);
-        return NULL;
+        LOGE("Unknown primitive type '%c'\n", type);
+        dvmAbort();
+        return NULL; // Keeps the compiler happy.
     }
 
-    if (*pTypeClass == NULL) {
-        char typeClassName[3] = "[x";
-
-        typeClassName[1] = type;
-
-        *pTypeClass = dvmFindArrayClass(typeClassName, NULL);
-        if (*pTypeClass == NULL) {
-            LOGE("ERROR: failed to generate array class for '%s'\n",
-                typeClassName);
-            return NULL;
-        }
-    }
-
-    newArray = dvmAllocArray(*pTypeClass, length, width, allocFlags);
+    newArray = dvmAllocArray(arrayClass, length, width, allocFlags);
 
     /* the caller must dvmReleaseTrackedAlloc if allocFlags==ALLOC_DEFAULT */
     return newArray;