8334772: Change Class::signers to an explicit field
Reviewed-by: dholmes, alanb, rriggs, coleenp
This commit is contained in:
parent
902c2afb67
commit
39f4476813
@ -1220,10 +1220,6 @@ objArrayOop java_lang_Class::signers(oop java_class) {
|
|||||||
assert(_signers_offset != 0, "must be set");
|
assert(_signers_offset != 0, "must be set");
|
||||||
return (objArrayOop)java_class->obj_field(_signers_offset);
|
return (objArrayOop)java_class->obj_field(_signers_offset);
|
||||||
}
|
}
|
||||||
void java_lang_Class::set_signers(oop java_class, objArrayOop signers) {
|
|
||||||
assert(_signers_offset != 0, "must be set");
|
|
||||||
java_class->obj_field_put(_signers_offset, signers);
|
|
||||||
}
|
|
||||||
|
|
||||||
oop java_lang_Class::class_data(oop java_class) {
|
oop java_lang_Class::class_data(oop java_class) {
|
||||||
assert(_classData_offset != 0, "must be set");
|
assert(_classData_offset != 0, "must be set");
|
||||||
@ -1418,12 +1414,13 @@ oop java_lang_Class::primitive_mirror(BasicType t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define CLASS_FIELDS_DO(macro) \
|
#define CLASS_FIELDS_DO(macro) \
|
||||||
macro(_classRedefinedCount_offset, k, "classRedefinedCount", int_signature, false); \
|
macro(_classRedefinedCount_offset, k, "classRedefinedCount", int_signature, false); \
|
||||||
macro(_class_loader_offset, k, "classLoader", classloader_signature, false); \
|
macro(_class_loader_offset, k, "classLoader", classloader_signature, false); \
|
||||||
macro(_component_mirror_offset, k, "componentType", class_signature, false); \
|
macro(_component_mirror_offset, k, "componentType", class_signature, false); \
|
||||||
macro(_module_offset, k, "module", module_signature, false); \
|
macro(_module_offset, k, "module", module_signature, false); \
|
||||||
macro(_name_offset, k, "name", string_signature, false); \
|
macro(_name_offset, k, "name", string_signature, false); \
|
||||||
macro(_classData_offset, k, "classData", object_signature, false);
|
macro(_classData_offset, k, "classData", object_signature, false); \
|
||||||
|
macro(_signers_offset, k, "signers", object_array_signature, false);
|
||||||
|
|
||||||
void java_lang_Class::compute_offsets() {
|
void java_lang_Class::compute_offsets() {
|
||||||
if (_offsets_computed) {
|
if (_offsets_computed) {
|
||||||
|
@ -208,7 +208,6 @@ class java_lang_String : AllStatic {
|
|||||||
macro(java_lang_Class, oop_size, int_signature, false) \
|
macro(java_lang_Class, oop_size, int_signature, false) \
|
||||||
macro(java_lang_Class, static_oop_field_count, int_signature, false) \
|
macro(java_lang_Class, static_oop_field_count, int_signature, false) \
|
||||||
macro(java_lang_Class, protection_domain, object_signature, false) \
|
macro(java_lang_Class, protection_domain, object_signature, false) \
|
||||||
macro(java_lang_Class, signers, object_signature, false) \
|
|
||||||
macro(java_lang_Class, source_file, object_signature, false) \
|
macro(java_lang_Class, source_file, object_signature, false) \
|
||||||
|
|
||||||
class java_lang_Class : AllStatic {
|
class java_lang_Class : AllStatic {
|
||||||
@ -299,8 +298,7 @@ class java_lang_Class : AllStatic {
|
|||||||
set_init_lock(java_class, nullptr);
|
set_init_lock(java_class, nullptr);
|
||||||
}
|
}
|
||||||
static oop component_mirror(oop java_class);
|
static oop component_mirror(oop java_class);
|
||||||
static objArrayOop signers(oop java_class);
|
static objArrayOop signers(oop java_class);
|
||||||
static void set_signers(oop java_class, objArrayOop signers);
|
|
||||||
static oop class_data(oop java_class);
|
static oop class_data(oop java_class);
|
||||||
static void set_class_data(oop java_class, oop classData);
|
static void set_class_data(oop java_class, oop classData);
|
||||||
|
|
||||||
|
@ -552,12 +552,6 @@ JVM_GetClassInterfaces(JNIEnv *env, jclass cls);
|
|||||||
JNIEXPORT jboolean JNICALL
|
JNIEXPORT jboolean JNICALL
|
||||||
JVM_IsInterface(JNIEnv *env, jclass cls);
|
JVM_IsInterface(JNIEnv *env, jclass cls);
|
||||||
|
|
||||||
JNIEXPORT jobjectArray JNICALL
|
|
||||||
JVM_GetClassSigners(JNIEnv *env, jclass cls);
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
|
||||||
JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers);
|
|
||||||
|
|
||||||
JNIEXPORT jobject JNICALL
|
JNIEXPORT jobject JNICALL
|
||||||
JVM_GetProtectionDomain(JNIEnv *env, jclass cls);
|
JVM_GetProtectionDomain(JNIEnv *env, jclass cls);
|
||||||
|
|
||||||
|
@ -1252,45 +1252,6 @@ JVM_ENTRY(jboolean, JVM_IsHiddenClass(JNIEnv *env, jclass cls))
|
|||||||
return k->is_hidden();
|
return k->is_hidden();
|
||||||
JVM_END
|
JVM_END
|
||||||
|
|
||||||
JVM_ENTRY(jobjectArray, JVM_GetClassSigners(JNIEnv *env, jclass cls))
|
|
||||||
JvmtiVMObjectAllocEventCollector oam;
|
|
||||||
oop mirror = JNIHandles::resolve_non_null(cls);
|
|
||||||
if (java_lang_Class::is_primitive(mirror)) {
|
|
||||||
// There are no signers for primitive types
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
objArrayHandle signers(THREAD, java_lang_Class::signers(mirror));
|
|
||||||
|
|
||||||
// If there are no signers set in the class, or if the class
|
|
||||||
// is an array, return null.
|
|
||||||
if (signers == nullptr) return nullptr;
|
|
||||||
|
|
||||||
// copy of the signers array
|
|
||||||
Klass* element = ObjArrayKlass::cast(signers->klass())->element_klass();
|
|
||||||
objArrayOop signers_copy = oopFactory::new_objArray(element, signers->length(), CHECK_NULL);
|
|
||||||
for (int index = 0; index < signers->length(); index++) {
|
|
||||||
signers_copy->obj_at_put(index, signers->obj_at(index));
|
|
||||||
}
|
|
||||||
|
|
||||||
// return the copy
|
|
||||||
return (jobjectArray) JNIHandles::make_local(THREAD, signers_copy);
|
|
||||||
JVM_END
|
|
||||||
|
|
||||||
|
|
||||||
JVM_ENTRY(void, JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers))
|
|
||||||
oop mirror = JNIHandles::resolve_non_null(cls);
|
|
||||||
if (!java_lang_Class::is_primitive(mirror)) {
|
|
||||||
// This call is ignored for primitive types and arrays.
|
|
||||||
// Signers are only set once, ClassLoader.java, and thus shouldn't
|
|
||||||
// be called with an array. Only the bootstrap loader creates arrays.
|
|
||||||
Klass* k = java_lang_Class::as_Klass(mirror);
|
|
||||||
if (k->is_instance_klass()) {
|
|
||||||
java_lang_Class::set_signers(k->java_mirror(), objArrayOop(JNIHandles::resolve(signers)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
JVM_END
|
|
||||||
|
|
||||||
|
|
||||||
JVM_ENTRY(jobject, JVM_GetProtectionDomain(JNIEnv *env, jclass cls))
|
JVM_ENTRY(jobject, JVM_GetProtectionDomain(JNIEnv *env, jclass cls))
|
||||||
oop mirror = JNIHandles::resolve_non_null(cls);
|
oop mirror = JNIHandles::resolve_non_null(cls);
|
||||||
|
@ -1110,8 +1110,8 @@ public final class Class<T> implements java.io.Serializable,
|
|||||||
// will throw NoSuchFieldException
|
// will throw NoSuchFieldException
|
||||||
private final ClassLoader classLoader;
|
private final ClassLoader classLoader;
|
||||||
|
|
||||||
// Set by VM
|
private transient Object classData; // Set by VM
|
||||||
private transient Object classData;
|
private transient Object[] signers; // Read by VM, mutable
|
||||||
|
|
||||||
// package-private
|
// package-private
|
||||||
Object getClassData() {
|
Object getClassData() {
|
||||||
@ -1510,14 +1510,19 @@ public final class Class<T> implements java.io.Serializable,
|
|||||||
* a primitive type or void.
|
* a primitive type or void.
|
||||||
* @since 1.1
|
* @since 1.1
|
||||||
*/
|
*/
|
||||||
public native Object[] getSigners();
|
public Object[] getSigners() {
|
||||||
|
var signers = this.signers;
|
||||||
|
return signers == null ? null : signers.clone();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the signers of this class.
|
* Set the signers of this class.
|
||||||
*/
|
*/
|
||||||
native void setSigners(Object[] signers);
|
void setSigners(Object[] signers) {
|
||||||
|
if (!isPrimitive() && !isArray()) {
|
||||||
|
this.signers = signers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this {@code Class} object represents a local or anonymous
|
* If this {@code Class} object represents a local or anonymous
|
||||||
|
@ -58,8 +58,6 @@ static JNINativeMethod methods[] = {
|
|||||||
{"getSuperclass", "()" CLS, NULL},
|
{"getSuperclass", "()" CLS, NULL},
|
||||||
{"getInterfaces0", "()[" CLS, (void *)&JVM_GetClassInterfaces},
|
{"getInterfaces0", "()[" CLS, (void *)&JVM_GetClassInterfaces},
|
||||||
{"isInterface", "()Z", (void *)&JVM_IsInterface},
|
{"isInterface", "()Z", (void *)&JVM_IsInterface},
|
||||||
{"getSigners", "()[" OBJ, (void *)&JVM_GetClassSigners},
|
|
||||||
{"setSigners", "([" OBJ ")V", (void *)&JVM_SetClassSigners},
|
|
||||||
{"isArray", "()Z", (void *)&JVM_IsArrayClass},
|
{"isArray", "()Z", (void *)&JVM_IsArrayClass},
|
||||||
{"isHidden", "()Z", (void *)&JVM_IsHiddenClass},
|
{"isHidden", "()Z", (void *)&JVM_IsHiddenClass},
|
||||||
{"isPrimitive", "()Z", (void *)&JVM_IsPrimitiveClass},
|
{"isPrimitive", "()Z", (void *)&JVM_IsPrimitiveClass},
|
||||||
|
Loading…
Reference in New Issue
Block a user