mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-26 07:40:09 +00:00
8196601: IllegalAccessError: cannot access class jdk.jfr.internal.handlers.EventHandler
Do not perform access check when returning a reflection field or method or performing internal signature processing. Reviewed-by: acorn, psandoz
This commit is contained in:
parent
44ab590f44
commit
2f74993973
@ -765,26 +765,27 @@ void Reflection::check_for_inner_class(const InstanceKlass* outer, const Instanc
|
||||
static oop get_mirror_from_signature(const methodHandle& method,
|
||||
SignatureStream* ss,
|
||||
TRAPS) {
|
||||
Klass* accessing_klass = method->method_holder();
|
||||
assert(accessing_klass != NULL, "method has no accessing_klass");
|
||||
|
||||
oop mirror_oop = ss->as_java_mirror(Handle(THREAD, accessing_klass->class_loader()),
|
||||
Handle(THREAD, accessing_klass->protection_domain()),
|
||||
SignatureStream::NCDFError,
|
||||
CHECK_NULL);
|
||||
|
||||
// Special tracing logic for resolution of class names during reflection.
|
||||
if (log_is_enabled(Debug, class, resolve)) {
|
||||
Klass* result = java_lang_Class::as_Klass(mirror_oop);
|
||||
if (result != NULL) {
|
||||
trace_class_resolution(result);
|
||||
if (T_OBJECT == ss->type() || T_ARRAY == ss->type()) {
|
||||
Symbol* name = ss->as_symbol(CHECK_NULL);
|
||||
oop loader = method->method_holder()->class_loader();
|
||||
oop protection_domain = method->method_holder()->protection_domain();
|
||||
const Klass* k = SystemDictionary::resolve_or_fail(name,
|
||||
Handle(THREAD, loader),
|
||||
Handle(THREAD, protection_domain),
|
||||
true,
|
||||
CHECK_NULL);
|
||||
if (log_is_enabled(Debug, class, resolve)) {
|
||||
trace_class_resolution(k);
|
||||
}
|
||||
return k->java_mirror();
|
||||
}
|
||||
|
||||
assert(ss->type() != T_VOID || ss->at_return_type(),
|
||||
"T_VOID should only appear as return type");
|
||||
|
||||
return mirror_oop;
|
||||
return java_lang_Class::primitive_mirror(ss->type());
|
||||
}
|
||||
|
||||
static objArrayHandle get_parameter_types(const methodHandle& method,
|
||||
@ -818,17 +819,24 @@ static objArrayHandle get_exception_types(const methodHandle& method, TRAPS) {
|
||||
}
|
||||
|
||||
static Handle new_type(Symbol* signature, Klass* k, TRAPS) {
|
||||
Handle mirror = SystemDictionary::find_java_mirror_for_type(signature, k, SignatureStream::NCDFError, CHECK_(Handle()));
|
||||
|
||||
// Special tracing logic for resolution of class names during reflection.
|
||||
if (log_is_enabled(Debug, class, resolve)) {
|
||||
Klass* result = java_lang_Class::as_Klass(mirror());
|
||||
if (result != NULL) {
|
||||
trace_class_resolution(result);
|
||||
}
|
||||
// Basic types
|
||||
BasicType type = vmSymbols::signature_type(signature);
|
||||
if (type != T_OBJECT) {
|
||||
return Handle(THREAD, Universe::java_mirror(type));
|
||||
}
|
||||
|
||||
return mirror;
|
||||
Klass* result =
|
||||
SystemDictionary::resolve_or_fail(signature,
|
||||
Handle(THREAD, k->class_loader()),
|
||||
Handle(THREAD, k->protection_domain()),
|
||||
true, CHECK_(Handle()));
|
||||
|
||||
if (log_is_enabled(Debug, class, resolve)) {
|
||||
trace_class_resolution(result);
|
||||
}
|
||||
|
||||
oop nt = result->java_mirror();
|
||||
return Handle(THREAD, nt);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -392,19 +392,11 @@ Klass* SignatureStream::as_klass(Handle class_loader, Handle protection_domain,
|
||||
|
||||
oop SignatureStream::as_java_mirror(Handle class_loader, Handle protection_domain,
|
||||
FailureMode failure_mode, TRAPS) {
|
||||
if (raw_length() == 1) {
|
||||
// short-cut in a common case
|
||||
return SystemDictionary::find_java_mirror_for_type((char) raw_byte_at(0));
|
||||
}
|
||||
TempNewSymbol signature = SymbolTable::new_symbol(_signature, _begin, _end, CHECK_NULL);
|
||||
Klass* no_accessing_klass = NULL;
|
||||
Handle mirror = SystemDictionary::find_java_mirror_for_type(signature,
|
||||
no_accessing_klass,
|
||||
class_loader,
|
||||
protection_domain,
|
||||
failure_mode,
|
||||
CHECK_NULL);
|
||||
return mirror();
|
||||
if (!is_object())
|
||||
return Universe::java_mirror(type());
|
||||
Klass* klass = as_klass(class_loader, protection_domain, failure_mode, CHECK_NULL);
|
||||
if (klass == NULL) return NULL;
|
||||
return klass->java_mirror();
|
||||
}
|
||||
|
||||
Symbol* SignatureStream::as_symbol_or_null() {
|
||||
|
||||
@ -409,11 +409,6 @@ class SignatureStream : public StackObj {
|
||||
const jbyte* raw_bytes() { return _signature->bytes() + _begin; }
|
||||
int raw_length() { return _end - _begin; }
|
||||
|
||||
jbyte raw_byte_at(int index) {
|
||||
assert(index >= 0 && index < raw_length(), "index overflow");
|
||||
return _signature->byte_at(_begin + index);
|
||||
}
|
||||
|
||||
// return same as_symbol except allocation of new symbols is avoided.
|
||||
Symbol* as_symbol_or_null();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user