8047737: Move array component mirror to instance of java/lang/Class

Add field in java.lang.Class for componentType to simplify oop processing in JVM

Reviewed-by: fparain, twisti, mchung
This commit is contained in:
Coleen Phillimore 2014-07-02 16:47:49 -04:00
parent c3790a3026
commit cbb6f307df
3 changed files with 12 additions and 6 deletions

View File

@ -134,10 +134,11 @@ public final class Class<T> implements java.io.Serializable,
* 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 @@ public final class Class<T> implements java.io.Serializable,
* @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;
/**

View File

@ -444,9 +444,6 @@ JVM_IsArrayClass(JNIEnv *env, jclass cls);
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);

View File

@ -60,7 +60,6 @@ static JNINativeMethod methods[] = {
{"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},