Skip to content
Permalink
Browse files
8198698: Support Lambda proxy classes in dynamic CDS archive
Added archving of hidden classes of type lambda proxy classes.

Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Reviewed-by: mchung, iklam, dholmes
  • Loading branch information
calvinccheung and ioilam committed Jun 10, 2020
1 parent 268d870 commit 847a3baca8a19b4f506dcaf23079e1b339e5321b
Showing 57 changed files with 3,724 additions and 39 deletions.
@@ -143,6 +143,8 @@ JVM_InternString
JVM_Interrupt
JVM_InvokeMethod
JVM_IsArrayClass
JVM_IsCDSDumpingEnabled
JVM_IsCDSSharingEnabled
JVM_IsConstructorIx
JVM_IsHiddenClass
JVM_IsInterface
@@ -155,6 +157,7 @@ JVM_IsVMGeneratedMethodIx
JVM_LatestUserDefinedLoader
JVM_LoadLibrary
JVM_LookupDefineClass
JVM_LookupLambdaProxyClassFromArchive
JVM_MaxMemory
JVM_MaxObjectInspectionAge
JVM_MonitorNotify
@@ -171,6 +174,7 @@ JVM_RawMonitorCreate
JVM_RawMonitorDestroy
JVM_RawMonitorEnter
JVM_RawMonitorExit
JVM_RegisterLambdaProxyClassForArchiving
JVM_RegisterSignal
JVM_ReleaseUTF
JVM_ResumeThread
@@ -703,7 +703,7 @@ InstanceKlass* SystemDictionary::handle_parallel_super_load(
return NULL;
}

static void post_class_load_event(EventClassLoad* event, const InstanceKlass* k, const ClassLoaderData* init_cld) {
void SystemDictionary::post_class_load_event(EventClassLoad* event, const InstanceKlass* k, const ClassLoaderData* init_cld) {
assert(event != NULL, "invariant");
assert(k != NULL, "invariant");
assert(event->should_commit(), "invariant");
@@ -1369,6 +1369,37 @@ bool SystemDictionary::check_shared_class_super_types(InstanceKlass* ik, Handle
return true;
}

InstanceKlass* SystemDictionary::load_shared_lambda_proxy_class(InstanceKlass* ik,
Handle class_loader,
Handle protection_domain,
PackageEntry* pkg_entry,
TRAPS) {
InstanceKlass* shared_nest_host = SystemDictionaryShared::get_shared_nest_host(ik);
assert(shared_nest_host->is_shared(), "nest host must be in CDS archive");
Symbol* cn = shared_nest_host->name();
Klass *s = resolve_or_fail(cn, class_loader, protection_domain, true, CHECK_NULL);
if (s != shared_nest_host) {
// The dynamically resolved nest_host is not the same as the one we used during dump time,
// so we cannot use ik.
return NULL;
} else {
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, THREAD);

InstanceKlass* loaded_ik = load_shared_class(ik, class_loader, protection_domain, NULL, pkg_entry, CHECK_NULL);

assert(shared_nest_host->is_same_class_package(ik),
"lambda proxy class and its nest host must be in the same package");

return loaded_ik;
}

InstanceKlass* SystemDictionary::load_shared_class(InstanceKlass* ik,
Handle class_loader,
Handle protection_domain,
@@ -1389,8 +1420,13 @@ InstanceKlass* SystemDictionary::load_shared_class(InstanceKlass* ik,
return NULL;
}

InstanceKlass* new_ik = KlassFactory::check_shared_class_file_load_hook(
InstanceKlass* new_ik = NULL;
// CFLH check is skipped for VM hidden or anonymous classes (see KlassFactory::create_from_stream).
// It will be skipped for shared VM hidden lambda proxy classes.
if (!SystemDictionaryShared::is_hidden_lambda_proxy(ik)) {
new_ik = KlassFactory::check_shared_class_file_load_hook(
ik, class_name, class_loader, protection_domain, cfs, CHECK_NULL);
}
if (new_ik != NULL) {
// The class is changed by CFLH. Return the new class. The shared class is
// not used.
@@ -132,6 +132,7 @@ class SymbolPropertyTable;
class ProtectionDomainCacheTable;
class ProtectionDomainCacheEntry;
class GCTimer;
class EventClassLoad;

#define WK_KLASS_ENUM_NAME(kname) kname##_knum

@@ -606,6 +607,7 @@ class SystemDictionary : AllStatic {
static LoaderConstraintTable* constraints() { return _loader_constraints; }
static ResolutionErrorTable* resolution_errors() { return _resolution_errors; }
static SymbolPropertyTable* invoke_method_table() { return _invoke_method_table; }
static void post_class_load_event(EventClassLoad* event, const InstanceKlass* k, const ClassLoaderData* init_cld);

// Basic loading operations
static InstanceKlass* resolve_instance_class_or_null_helper(Symbol* name,
@@ -632,6 +634,11 @@ class SystemDictionary : AllStatic {
bool is_superclass, TRAPS);
static bool check_shared_class_super_types(InstanceKlass* ik, Handle class_loader,
Handle protection_domain, TRAPS);
static InstanceKlass* load_shared_lambda_proxy_class(InstanceKlass* ik,
Handle class_loader,
Handle protection_domain,
PackageEntry* pkg_entry,
TRAPS);
static InstanceKlass* load_shared_class(InstanceKlass* ik,
Handle class_loader,
Handle protection_domain,

0 comments on commit 847a3ba

Please sign in to comment.