mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-11 02:48:20 +00:00
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:
parent
c3790a3026
commit
cbb6f307df
@ -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;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user