8296433: Encountered null CLD while loading shared lambda proxy class

Reviewed-by: iklam, dholmes
This commit is contained in:
Calvin Cheung 2022-11-08 21:55:51 +00:00
parent 74f2b16a8e
commit d04d6566b0
2 changed files with 7 additions and 6 deletions

View file

@ -1170,12 +1170,6 @@ InstanceKlass* SystemDictionary::load_shared_lambda_proxy_class(InstanceKlass* i
assert(s->is_shared(), "must be"); assert(s->is_shared(), "must be");
} }
// The lambda proxy class and its nest host have the same class loader and class loader data,
// as verified in SystemDictionaryShared::add_lambda_proxy_class()
assert(shared_nest_host->class_loader() == class_loader(), "mismatched class loader");
assert(shared_nest_host->class_loader_data() == ClassLoaderData::class_loader_data(class_loader()), "mismatched class loader data");
ik->set_nest_host(shared_nest_host);
InstanceKlass* loaded_ik = load_shared_class(ik, class_loader, protection_domain, NULL, pkg_entry, CHECK_NULL); InstanceKlass* loaded_ik = load_shared_class(ik, class_loader, protection_domain, NULL, pkg_entry, CHECK_NULL);
if (loaded_ik != NULL) { if (loaded_ik != NULL) {
@ -1183,6 +1177,12 @@ InstanceKlass* SystemDictionary::load_shared_lambda_proxy_class(InstanceKlass* i
"lambda proxy class and its nest host must be in the same package"); "lambda proxy class and its nest host must be in the same package");
} }
// The lambda proxy class and its nest host have the same class loader and class loader data,
// as verified in SystemDictionaryShared::add_lambda_proxy_class()
assert(shared_nest_host->class_loader() == class_loader(), "mismatched class loader");
assert(shared_nest_host->class_loader_data() == ClassLoaderData::class_loader_data(class_loader()), "mismatched class loader data");
ik->set_nest_host(shared_nest_host);
return loaded_ik; return loaded_ik;
} }

View file

@ -387,6 +387,7 @@ void InstanceKlass::set_nest_host(InstanceKlass* host) {
_nest_host = host; _nest_host = host;
// Record dependency to keep nest host from being unloaded before this class. // Record dependency to keep nest host from being unloaded before this class.
ClassLoaderData* this_key = class_loader_data(); ClassLoaderData* this_key = class_loader_data();
assert(this_key != NULL, "sanity");
this_key->record_dependency(host); this_key->record_dependency(host);
} }