8189123: More consistent classloading

Reviewed-by: acorn, ahgross, rhalade
This commit is contained in:
Harold Seigel 2017-11-07 16:07:36 -05:00 committed by Harold Seigel
parent 278672706d
commit f988f60dc8
3 changed files with 13 additions and 3 deletions

View File

@ -50,6 +50,7 @@ bool VerificationType::resolve_and_check_assignability(InstanceKlass* klass, Sym
Klass* this_class = SystemDictionary::resolve_or_fail( Klass* this_class = SystemDictionary::resolve_or_fail(
name, Handle(THREAD, klass->class_loader()), name, Handle(THREAD, klass->class_loader()),
Handle(THREAD, klass->protection_domain()), true, CHECK_false); Handle(THREAD, klass->protection_domain()), true, CHECK_false);
klass->class_loader_data()->record_dependency(this_class);
if (log_is_enabled(Debug, class, resolve)) { if (log_is_enabled(Debug, class, resolve)) {
Verifier::trace_class_resolution(this_class, klass); Verifier::trace_class_resolution(this_class, klass);
} }
@ -67,6 +68,7 @@ bool VerificationType::resolve_and_check_assignability(InstanceKlass* klass, Sym
Klass* from_class = SystemDictionary::resolve_or_fail( Klass* from_class = SystemDictionary::resolve_or_fail(
from_name, Handle(THREAD, klass->class_loader()), from_name, Handle(THREAD, klass->class_loader()),
Handle(THREAD, klass->protection_domain()), true, CHECK_false); Handle(THREAD, klass->protection_domain()), true, CHECK_false);
klass->class_loader_data()->record_dependency(from_class);
if (log_is_enabled(Debug, class, resolve)) { if (log_is_enabled(Debug, class, resolve)) {
Verifier::trace_class_resolution(from_class, klass); Verifier::trace_class_resolution(from_class, klass);
} }

View File

@ -2013,9 +2013,12 @@ Klass* ClassVerifier::load_class(Symbol* name, TRAPS) {
name, Handle(THREAD, loader), Handle(THREAD, protection_domain), name, Handle(THREAD, loader), Handle(THREAD, protection_domain),
true, THREAD); true, THREAD);
if (log_is_enabled(Debug, class, resolve)) { if (kls != NULL) {
InstanceKlass* cur_class = InstanceKlass::cast(current_class()); current_class()->class_loader_data()->record_dependency(kls);
Verifier::trace_class_resolution(kls, cur_class); if (log_is_enabled(Debug, class, resolve)) {
InstanceKlass* cur_class = InstanceKlass::cast(current_class());
Verifier::trace_class_resolution(kls, cur_class);
}
} }
return kls; return kls;
} }

View File

@ -839,6 +839,11 @@ JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name,
Handle h_prot (THREAD, protection_domain); Handle h_prot (THREAD, protection_domain);
jclass result = find_class_from_class_loader(env, h_name, init, h_loader, jclass result = find_class_from_class_loader(env, h_name, init, h_loader,
h_prot, true, thread); h_prot, true, thread);
if (result != NULL) {
oop mirror = JNIHandles::resolve_non_null(result);
Klass* to_class = java_lang_Class::as_Klass(mirror);
ClassLoaderData::class_loader_data(h_loader())->record_dependency(to_class);
}
if (log_is_enabled(Debug, class, resolve) && result != NULL) { if (log_is_enabled(Debug, class, resolve) && result != NULL) {
// this function is generally only used for class loading during verification. // this function is generally only used for class loading during verification.