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
--- 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},