changeset 25517:f3c83ab83a16

8047737: Move array component mirror to instance of java/lang/Class Summary: Add field in java.lang.Class for componentType to simplify oop processing in JVM Reviewed-by: fparain, twisti, mchung
author coleenp
date Wed, 02 Jul 2014 16:47:49 -0400
parents 5cd1551307d4
children f7d25a9ba99c
files jdk/src/share/classes/java/lang/Class.java jdk/src/share/javavm/export/jvm.h jdk/src/share/native/java/lang/Class.c
diffstat 3 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/share/classes/java/lang/Class.java	Fri Jun 27 14:21:31 2014 -0700
+++ b/jdk/src/share/classes/java/lang/Class.java	Wed Jul 02 16:47:49 2014 -0400
@@ -134,10 +134,11 @@
      * This constructor is not used and prevents the default constructor being
      * generated.
      */
-    private Class(ClassLoader loader) {
+    private Class(ClassLoader loader, Class<?> arrayComponentType) {
         // Initialize final field for classLoader.  The initialization value of non-null
         // prevents future JIT optimizations from assuming this final field is null.
         classLoader = loader;
+        componentType = arrayComponentType;
     }
 
     /**
@@ -917,7 +918,16 @@
      * @see     java.lang.reflect.Array
      * @since 1.1
      */
-    public native Class<?> getComponentType();
+    public Class<?> getComponentType() {
+        // Only return for array types. Storage may be reused for Class for instance types.
+        if (isArray()) {
+            return componentType;
+        } else {
+            return null;
+        }
+    }
+
+    private final Class<?> componentType;
 
 
     /**
--- a/jdk/src/share/javavm/export/jvm.h	Fri Jun 27 14:21:31 2014 -0700
+++ b/jdk/src/share/javavm/export/jvm.h	Wed Jul 02 16:47:49 2014 -0400
@@ -444,9 +444,6 @@
 JNIEXPORT jboolean JNICALL
 JVM_IsPrimitiveClass(JNIEnv *env, jclass cls);
 
-JNIEXPORT jclass JNICALL
-JVM_GetComponentType(JNIEnv *env, jclass cls);
-
 JNIEXPORT jint JNICALL
 JVM_GetClassModifiers(JNIEnv *env, jclass cls);
 
--- a/jdk/src/share/native/java/lang/Class.c	Fri Jun 27 14:21:31 2014 -0700
+++ b/jdk/src/share/native/java/lang/Class.c	Wed Jul 02 16:47:49 2014 -0400
@@ -60,7 +60,6 @@
     {"setSigners",       "([" OBJ ")V",     (void *)&JVM_SetClassSigners},
     {"isArray",          "()Z",             (void *)&JVM_IsArrayClass},
     {"isPrimitive",      "()Z",             (void *)&JVM_IsPrimitiveClass},
-    {"getComponentType", "()" CLS,          (void *)&JVM_GetComponentType},
     {"getModifiers",     "()I",             (void *)&JVM_GetClassModifiers},
     {"getDeclaredFields0","(Z)[" FLD,       (void *)&JVM_GetClassDeclaredFields},
     {"getDeclaredMethods0","(Z)[" MHD,      (void *)&JVM_GetClassDeclaredMethods},