--- old/src/hotspot/share/classfile/systemDictionaryShared.cpp 2020-06-05 01:14:52.510726984 +0000 +++ new/src/hotspot/share/classfile/systemDictionaryShared.cpp 2020-06-05 01:14:51.088692382 +0000 @@ -36,6 +36,7 @@ #include "classfile/systemDictionaryShared.hpp" #include "classfile/verificationType.hpp" #include "classfile/vmSymbols.hpp" +#include "jfr/jfrEvents.hpp" #include "logging/log.hpp" #include "memory/allocation.hpp" #include "memory/archiveUtils.hpp" @@ -1667,9 +1668,9 @@ return record->nest_host(); } -InstanceKlass* SystemDictionaryShared::load_shared_lambda_proxy_class(InstanceKlass* lambda_ik, - InstanceKlass* caller_ik, - bool initialize, TRAPS) { +InstanceKlass* SystemDictionaryShared::prepare_shared_lambda_proxy_class(InstanceKlass* lambda_ik, + InstanceKlass* caller_ik, + bool initialize, TRAPS) { Handle class_loader(THREAD, caller_ik->class_loader()); Handle protection_domain; PackageEntry* pkg_entry = get_package_entry_from_class_name(class_loader, caller_ik->name()); @@ -1681,15 +1682,36 @@ assert(shared_nest_host != NULL, "unexpected NULL _nest_host"); InstanceKlass* loaded_lambda = - SystemDictionary::load_shared_lambda_proxy_class(lambda_ik, class_loader, protection_domain, pkg_entry, initialize, CHECK_NULL); + SystemDictionary::load_shared_lambda_proxy_class(lambda_ik, class_loader, protection_domain, pkg_entry, CHECK_NULL); - InstanceKlass* nest_host = caller_ik->nest_host(THREAD); - // The following ensures that the caller's nest host is the same as the lambda proxy's + // Ensures the nest host is the same as the lambda proxy's // nest host recorded at dump time. - assert(nest_host->has_nest_member(caller_ik, THREAD) || - nest_host == caller_ik, "caller_ik failed nest member check"); + InstanceKlass* nest_host = caller_ik->nest_host(THREAD); assert(nest_host == shared_nest_host, "mismatched nest host"); + EventClassLoad class_load_start_event; + { + MutexLocker mu_r(THREAD, Compile_lock); + + // Add to class hierarchy, initialize vtables, and do possible + // deoptimizations. + SystemDictionary::add_to_hierarchy(loaded_lambda, CHECK_NULL); // No exception, but can block + // But, do not add to dictionary. + } + loaded_lambda->link_class(CHECK_NULL); + // notify jvmti + if (JvmtiExport::should_post_class_load()) { + assert(THREAD->is_Java_thread(), "thread->is_Java_thread()"); + JvmtiExport::post_class_load((JavaThread *) THREAD, loaded_lambda); + } + if (class_load_start_event.should_commit()) { + SystemDictionary::post_class_load_event(&class_load_start_event, loaded_lambda, ClassLoaderData::class_loader_data(class_loader())); + } + + if (initialize) { + loaded_lambda->initialize(CHECK_NULL); + } + return loaded_lambda; }