39 #include "classfile/packageEntry.hpp"
40 #include "classfile/placeholders.hpp"
41 #include "classfile/protectionDomainCache.hpp"
42 #include "classfile/resolutionErrors.hpp"
43 #include "classfile/stringTable.hpp"
44 #include "classfile/symbolTable.hpp"
45 #include "classfile/systemDictionary.hpp"
46 #include "classfile/vmClasses.hpp"
47 #include "classfile/vmSymbols.hpp"
48 #include "gc/shared/gcTraceTime.inline.hpp"
49 #include "interpreter/bootstrapInfo.hpp"
50 #include "jfr/jfrEvents.hpp"
51 #include "jvm.h"
52 #include "logging/log.hpp"
53 #include "logging/logStream.hpp"
54 #include "memory/metaspaceClosure.hpp"
55 #include "memory/oopFactory.hpp"
56 #include "memory/resourceArea.hpp"
57 #include "memory/universe.hpp"
58 #include "oops/access.inline.hpp"
59 #include "oops/instanceKlass.hpp"
60 #include "oops/klass.inline.hpp"
61 #include "oops/method.inline.hpp"
62 #include "oops/objArrayKlass.hpp"
63 #include "oops/objArrayOop.inline.hpp"
64 #include "oops/oop.inline.hpp"
65 #include "oops/oop.hpp"
66 #include "oops/oopHandle.hpp"
67 #include "oops/oopHandle.inline.hpp"
68 #include "oops/symbol.hpp"
69 #include "oops/typeArrayKlass.hpp"
70 #include "prims/jvmtiExport.hpp"
71 #include "prims/methodHandles.hpp"
72 #include "runtime/arguments.hpp"
73 #include "runtime/atomic.hpp"
74 #include "runtime/handles.inline.hpp"
75 #include "runtime/java.hpp"
76 #include "runtime/javaCalls.hpp"
77 #include "runtime/mutexLocker.hpp"
78 #include "runtime/sharedRuntime.hpp"
79 #include "runtime/signature.hpp"
80 #include "runtime/synchronizer.hpp"
81 #include "services/classLoadingService.hpp"
82 #include "services/diagnosticCommand.hpp"
83 #include "services/finalizerService.hpp"
84 #include "services/threadService.hpp"
85 #include "utilities/macros.hpp"
86 #include "utilities/utf8.hpp"
87 #if INCLUDE_CDS
88 #include "classfile/systemDictionaryShared.hpp"
89 #endif
90 #if INCLUDE_JFR
91 #include "jfr/jfr.hpp"
92 #endif
93
94 class InvokeMethodKey : public StackObj {
95 private:
96 Symbol* _symbol;
97 intptr_t _iid;
332
333 Klass* SystemDictionary::resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain,
334 bool throw_error, TRAPS) {
335 Klass* klass = resolve_or_null(class_name, class_loader, protection_domain, THREAD);
336 // Check for pending exception or null klass, and throw exception
337 if (HAS_PENDING_EXCEPTION || klass == nullptr) {
338 handle_resolution_exception(class_name, throw_error, CHECK_NULL);
339 }
340 return klass;
341 }
342
343 // Forwards to resolve_array_class_or_null or resolve_instance_class_or_null
344
345 Klass* SystemDictionary::resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS) {
346 if (Signature::is_array(class_name)) {
347 return resolve_array_class_or_null(class_name, class_loader, protection_domain, THREAD);
348 } else {
349 assert(class_name != nullptr && !Signature::is_array(class_name), "must be");
350 if (Signature::has_envelope(class_name)) {
351 ResourceMark rm(THREAD);
352 // Ignore wrapping L and ;.
353 TempNewSymbol name = SymbolTable::new_symbol(class_name->as_C_string() + 1,
354 class_name->utf8_length() - 2);
355 return resolve_instance_class_or_null(name, class_loader, protection_domain, THREAD);
356 } else {
357 return resolve_instance_class_or_null(class_name, class_loader, protection_domain, THREAD);
358 }
359 }
360 }
361
362 // Forwards to resolve_instance_class_or_null
363
364 Klass* SystemDictionary::resolve_array_class_or_null(Symbol* class_name,
365 Handle class_loader,
366 Handle protection_domain,
367 TRAPS) {
368 assert(Signature::is_array(class_name), "must be array");
369 ResourceMark rm(THREAD);
370 SignatureStream ss(class_name, false);
371 int ndims = ss.skip_array_prefix(); // skip all '['s
372 Klass* k = nullptr;
437 }
438 }
439 #endif // INCLUDE_CDS
440
441 // If class_name is already loaded, just return the superclass or superinterface.
442 // Make sure there's a placeholder for the class_name before resolving.
443 // This is used as a claim that this thread is currently loading superclass/classloader
444 // and for ClassCircularity checks.
445
446 ClassLoaderData* loader_data = class_loader_data(class_loader);
447 Dictionary* dictionary = loader_data->dictionary();
448
449 // can't throw error holding a lock
450 bool throw_circularity_error = false;
451 {
452 MutexLocker mu(THREAD, SystemDictionary_lock);
453 InstanceKlass* klassk = dictionary->find_class(THREAD, class_name);
454 InstanceKlass* quicksuperk;
455 // To support parallel loading: if class is done loading, just return the superclass
456 // if the next_name matches class->super()->name() and if the class loaders match.
457 if (klassk != nullptr && is_superclass &&
458 ((quicksuperk = klassk->java_super()) != nullptr) &&
459 ((quicksuperk->name() == next_name) &&
460 (quicksuperk->class_loader() == class_loader()))) {
461 return quicksuperk;
462 } else {
463 // Must check ClassCircularity before checking if superclass is already loaded.
464 PlaceholderEntry* probe = PlaceholderTable::get_entry(class_name, loader_data);
465 if (probe && probe->check_seen_thread(THREAD, PlaceholderTable::DETECT_CIRCULARITY)) {
466 log_circularity_error(class_name, probe);
467 throw_circularity_error = true;
468 }
469 }
470
471 if (!throw_circularity_error) {
472 // Be careful not to exit resolve_with_circularity_detection without removing this placeholder.
473 PlaceholderEntry* newprobe = PlaceholderTable::find_and_add(class_name,
474 loader_data,
475 PlaceholderTable::DETECT_CIRCULARITY,
476 next_name, THREAD);
929
930 InstanceKlass* SystemDictionary::resolve_from_stream(ClassFileStream* st,
931 Symbol* class_name,
932 Handle class_loader,
933 const ClassLoadInfo& cl_info,
934 TRAPS) {
935 if (cl_info.is_hidden()) {
936 return resolve_hidden_class_from_stream(st, class_name, class_loader, cl_info, CHECK_NULL);
937 } else {
938 return resolve_class_from_stream(st, class_name, class_loader, cl_info, CHECK_NULL);
939 }
940 }
941
942
943 #if INCLUDE_CDS
944 // Check if a shared class can be loaded by the specific classloader.
945 bool SystemDictionary::is_shared_class_visible(Symbol* class_name,
946 InstanceKlass* ik,
947 PackageEntry* pkg_entry,
948 Handle class_loader) {
949 assert(!ModuleEntryTable::javabase_moduleEntry()->is_patched(),
950 "Cannot use sharing if java.base is patched");
951
952 // (1) Check if we are loading into the same loader as in dump time.
953
954 if (ik->is_shared_boot_class()) {
955 if (class_loader() != nullptr) {
956 return false;
957 }
958 } else if (ik->is_shared_platform_class()) {
959 if (class_loader() != java_platform_loader()) {
960 return false;
961 }
962 } else if (ik->is_shared_app_class()) {
963 if (class_loader() != java_system_loader()) {
964 return false;
965 }
966 } else {
967 // ik was loaded by a custom loader during dump time
968 if (class_loader_data(class_loader)->is_builtin_class_loader_data()) {
969 return false;
970 } else {
1006
1007 if (pkg_entry == nullptr) {
1008 // We might have looked up pkg_entry before the module system was initialized.
1009 // Need to reload it now.
1010 TempNewSymbol pkg_name = ClassLoader::package_from_class_name(class_name);
1011 if (pkg_name != nullptr) {
1012 pkg_entry = class_loader_data(class_loader)->packages()->lookup_only(pkg_name);
1013 }
1014 }
1015
1016 ModuleEntry* mod_entry = (pkg_entry == nullptr) ? nullptr : pkg_entry->module();
1017 bool should_be_in_named_module = (mod_entry != nullptr && mod_entry->is_named());
1018 bool was_archived_from_named_module = scp_entry->in_named_module();
1019 bool visible;
1020
1021 if (was_archived_from_named_module) {
1022 if (should_be_in_named_module) {
1023 // Is the module loaded from the same location as during dump time?
1024 visible = mod_entry->shared_path_index() == scp_index;
1025 if (visible) {
1026 assert(!mod_entry->is_patched(), "cannot load archived classes for patched module");
1027 }
1028 } else {
1029 // During dump time, this class was in a named module, but at run time, this class should be
1030 // in an unnamed module.
1031 visible = false;
1032 }
1033 } else {
1034 if (should_be_in_named_module) {
1035 // During dump time, this class was in an unnamed, but at run time, this class should be
1036 // in a named module.
1037 visible = false;
1038 } else {
1039 visible = true;
1040 }
1041 }
1042
1043 return visible;
1044 }
1045
1046 bool SystemDictionary::check_shared_class_super_type(InstanceKlass* klass, InstanceKlass* super_type,
1140 Handle protection_domain,
1141 const ClassFileStream *cfs,
1142 PackageEntry* pkg_entry,
1143 TRAPS) {
1144 assert(ik != nullptr, "sanity");
1145 assert(!ik->is_unshareable_info_restored(), "shared class can be restored only once");
1146 assert(Atomic::add(&ik->_shared_class_load_count, 1) == 1, "shared class loaded more than once");
1147 Symbol* class_name = ik->name();
1148
1149 if (!is_shared_class_visible(class_name, ik, pkg_entry, class_loader)) {
1150 ik->set_shared_loading_failed();
1151 return nullptr;
1152 }
1153
1154 bool check = check_shared_class_super_types(ik, class_loader, protection_domain, CHECK_NULL);
1155 if (!check) {
1156 ik->set_shared_loading_failed();
1157 return nullptr;
1158 }
1159
1160 InstanceKlass* new_ik = nullptr;
1161 // CFLH check is skipped for VM hidden classes (see KlassFactory::create_from_stream).
1162 // It will be skipped for shared VM hidden lambda proxy classes.
1163 if (!SystemDictionaryShared::is_hidden_lambda_proxy(ik)) {
1164 new_ik = KlassFactory::check_shared_class_file_load_hook(
1165 ik, class_name, class_loader, protection_domain, cfs, CHECK_NULL);
1166 }
1167 if (new_ik != nullptr) {
1168 // The class is changed by CFLH. Return the new class. The shared class is
1169 // not used.
1170 return new_ik;
1171 }
1172
1173 // Adjust methods to recover missing data. They need addresses for
1174 // interpreter entry points and their default native method address
1175 // must be reset.
1176
1177 // Shared classes are all currently loaded by either the bootstrap or
1178 // internal parallel class loaders, so this will never cause a deadlock
1179 // on a custom class loader lock.
1180 // Since this class is already locked with parallel capable class
1181 // loaders, including the bootstrap loader via the placeholder table,
1182 // this lock is currently a nop.
1183
1184 ClassLoaderData* loader_data = class_loader_data(class_loader);
1185 {
1186 HandleMark hm(THREAD);
1187 Handle lockObject = get_loader_lock_or_null(class_loader);
1188 ObjectLocker ol(lockObject, THREAD);
1189 // prohibited package check assumes all classes loaded from archive call
1190 // restore_unshareable_info which calls ik->set_package()
1191 ik->restore_unshareable_info(loader_data, protection_domain, pkg_entry, CHECK_NULL);
1192 }
1193
1194 load_shared_class_misc(ik, loader_data);
1195 return ik;
1196 }
1197
1198 void SystemDictionary::load_shared_class_misc(InstanceKlass* ik, ClassLoaderData* loader_data) {
1199 ik->print_class_load_logging(loader_data, nullptr, nullptr);
1200
1201 // For boot loader, ensure that GetSystemPackage knows that a class in this
1202 // package was loaded.
1203 if (loader_data->is_the_null_class_loader_data()) {
1204 s2 path_index = ik->shared_classpath_index();
1205 ik->set_classpath_index(path_index);
1206 }
1207
1208 // notify a class loaded from shared object
1209 ClassLoadingService::notify_class_loaded(ik, true /* shared class */);
1210 }
1211
1212 #endif // INCLUDE_CDS
1213
1214 InstanceKlass* SystemDictionary::load_instance_class_impl(Symbol* class_name, Handle class_loader, TRAPS) {
|
39 #include "classfile/packageEntry.hpp"
40 #include "classfile/placeholders.hpp"
41 #include "classfile/protectionDomainCache.hpp"
42 #include "classfile/resolutionErrors.hpp"
43 #include "classfile/stringTable.hpp"
44 #include "classfile/symbolTable.hpp"
45 #include "classfile/systemDictionary.hpp"
46 #include "classfile/vmClasses.hpp"
47 #include "classfile/vmSymbols.hpp"
48 #include "gc/shared/gcTraceTime.inline.hpp"
49 #include "interpreter/bootstrapInfo.hpp"
50 #include "jfr/jfrEvents.hpp"
51 #include "jvm.h"
52 #include "logging/log.hpp"
53 #include "logging/logStream.hpp"
54 #include "memory/metaspaceClosure.hpp"
55 #include "memory/oopFactory.hpp"
56 #include "memory/resourceArea.hpp"
57 #include "memory/universe.hpp"
58 #include "oops/access.inline.hpp"
59 #include "oops/fieldStreams.inline.hpp"
60 #include "oops/instanceKlass.hpp"
61 #include "oops/klass.inline.hpp"
62 #include "oops/method.inline.hpp"
63 #include "oops/objArrayKlass.hpp"
64 #include "oops/objArrayOop.inline.hpp"
65 #include "oops/oop.inline.hpp"
66 #include "oops/oop.hpp"
67 #include "oops/oopHandle.hpp"
68 #include "oops/oopHandle.inline.hpp"
69 #include "oops/symbol.hpp"
70 #include "oops/typeArrayKlass.hpp"
71 #include "oops/inlineKlass.inline.hpp"
72 #include "prims/jvmtiExport.hpp"
73 #include "prims/methodHandles.hpp"
74 #include "runtime/arguments.hpp"
75 #include "runtime/atomic.hpp"
76 #include "runtime/handles.inline.hpp"
77 #include "runtime/java.hpp"
78 #include "runtime/javaCalls.hpp"
79 #include "runtime/mutexLocker.hpp"
80 #include "runtime/os.hpp"
81 #include "runtime/sharedRuntime.hpp"
82 #include "runtime/signature.hpp"
83 #include "runtime/synchronizer.hpp"
84 #include "services/classLoadingService.hpp"
85 #include "services/diagnosticCommand.hpp"
86 #include "services/finalizerService.hpp"
87 #include "services/threadService.hpp"
88 #include "utilities/macros.hpp"
89 #include "utilities/utf8.hpp"
90 #if INCLUDE_CDS
91 #include "classfile/systemDictionaryShared.hpp"
92 #endif
93 #if INCLUDE_JFR
94 #include "jfr/jfr.hpp"
95 #endif
96
97 class InvokeMethodKey : public StackObj {
98 private:
99 Symbol* _symbol;
100 intptr_t _iid;
335
336 Klass* SystemDictionary::resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain,
337 bool throw_error, TRAPS) {
338 Klass* klass = resolve_or_null(class_name, class_loader, protection_domain, THREAD);
339 // Check for pending exception or null klass, and throw exception
340 if (HAS_PENDING_EXCEPTION || klass == nullptr) {
341 handle_resolution_exception(class_name, throw_error, CHECK_NULL);
342 }
343 return klass;
344 }
345
346 // Forwards to resolve_array_class_or_null or resolve_instance_class_or_null
347
348 Klass* SystemDictionary::resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS) {
349 if (Signature::is_array(class_name)) {
350 return resolve_array_class_or_null(class_name, class_loader, protection_domain, THREAD);
351 } else {
352 assert(class_name != nullptr && !Signature::is_array(class_name), "must be");
353 if (Signature::has_envelope(class_name)) {
354 ResourceMark rm(THREAD);
355 // Ignore wrapping L and ; (and Q and ; for value types).
356 TempNewSymbol name = SymbolTable::new_symbol(class_name->as_C_string() + 1,
357 class_name->utf8_length() - 2);
358 return resolve_instance_class_or_null(name, class_loader, protection_domain, THREAD);
359 } else {
360 return resolve_instance_class_or_null(class_name, class_loader, protection_domain, THREAD);
361 }
362 }
363 }
364
365 // Forwards to resolve_instance_class_or_null
366
367 Klass* SystemDictionary::resolve_array_class_or_null(Symbol* class_name,
368 Handle class_loader,
369 Handle protection_domain,
370 TRAPS) {
371 assert(Signature::is_array(class_name), "must be array");
372 ResourceMark rm(THREAD);
373 SignatureStream ss(class_name, false);
374 int ndims = ss.skip_array_prefix(); // skip all '['s
375 Klass* k = nullptr;
440 }
441 }
442 #endif // INCLUDE_CDS
443
444 // If class_name is already loaded, just return the superclass or superinterface.
445 // Make sure there's a placeholder for the class_name before resolving.
446 // This is used as a claim that this thread is currently loading superclass/classloader
447 // and for ClassCircularity checks.
448
449 ClassLoaderData* loader_data = class_loader_data(class_loader);
450 Dictionary* dictionary = loader_data->dictionary();
451
452 // can't throw error holding a lock
453 bool throw_circularity_error = false;
454 {
455 MutexLocker mu(THREAD, SystemDictionary_lock);
456 InstanceKlass* klassk = dictionary->find_class(THREAD, class_name);
457 InstanceKlass* quicksuperk;
458 // To support parallel loading: if class is done loading, just return the superclass
459 // if the next_name matches class->super()->name() and if the class loaders match.
460 // Otherwise, a LinkageError will be thrown later.
461 if (klassk != nullptr && is_superclass &&
462 ((quicksuperk = klassk->java_super()) != nullptr) &&
463 ((quicksuperk->name() == next_name) &&
464 (quicksuperk->class_loader() == class_loader()))) {
465 return quicksuperk;
466 } else {
467 // Must check ClassCircularity before checking if superclass is already loaded.
468 PlaceholderEntry* probe = PlaceholderTable::get_entry(class_name, loader_data);
469 if (probe && probe->check_seen_thread(THREAD, PlaceholderTable::DETECT_CIRCULARITY)) {
470 log_circularity_error(class_name, probe);
471 throw_circularity_error = true;
472 }
473 }
474
475 if (!throw_circularity_error) {
476 // Be careful not to exit resolve_with_circularity_detection without removing this placeholder.
477 PlaceholderEntry* newprobe = PlaceholderTable::find_and_add(class_name,
478 loader_data,
479 PlaceholderTable::DETECT_CIRCULARITY,
480 next_name, THREAD);
933
934 InstanceKlass* SystemDictionary::resolve_from_stream(ClassFileStream* st,
935 Symbol* class_name,
936 Handle class_loader,
937 const ClassLoadInfo& cl_info,
938 TRAPS) {
939 if (cl_info.is_hidden()) {
940 return resolve_hidden_class_from_stream(st, class_name, class_loader, cl_info, CHECK_NULL);
941 } else {
942 return resolve_class_from_stream(st, class_name, class_loader, cl_info, CHECK_NULL);
943 }
944 }
945
946
947 #if INCLUDE_CDS
948 // Check if a shared class can be loaded by the specific classloader.
949 bool SystemDictionary::is_shared_class_visible(Symbol* class_name,
950 InstanceKlass* ik,
951 PackageEntry* pkg_entry,
952 Handle class_loader) {
953 assert(!CDSConfig::module_patching_disables_cds(), "Cannot use CDS");
954
955 // (1) Check if we are loading into the same loader as in dump time.
956
957 if (ik->is_shared_boot_class()) {
958 if (class_loader() != nullptr) {
959 return false;
960 }
961 } else if (ik->is_shared_platform_class()) {
962 if (class_loader() != java_platform_loader()) {
963 return false;
964 }
965 } else if (ik->is_shared_app_class()) {
966 if (class_loader() != java_system_loader()) {
967 return false;
968 }
969 } else {
970 // ik was loaded by a custom loader during dump time
971 if (class_loader_data(class_loader)->is_builtin_class_loader_data()) {
972 return false;
973 } else {
1009
1010 if (pkg_entry == nullptr) {
1011 // We might have looked up pkg_entry before the module system was initialized.
1012 // Need to reload it now.
1013 TempNewSymbol pkg_name = ClassLoader::package_from_class_name(class_name);
1014 if (pkg_name != nullptr) {
1015 pkg_entry = class_loader_data(class_loader)->packages()->lookup_only(pkg_name);
1016 }
1017 }
1018
1019 ModuleEntry* mod_entry = (pkg_entry == nullptr) ? nullptr : pkg_entry->module();
1020 bool should_be_in_named_module = (mod_entry != nullptr && mod_entry->is_named());
1021 bool was_archived_from_named_module = scp_entry->in_named_module();
1022 bool visible;
1023
1024 if (was_archived_from_named_module) {
1025 if (should_be_in_named_module) {
1026 // Is the module loaded from the same location as during dump time?
1027 visible = mod_entry->shared_path_index() == scp_index;
1028 if (visible) {
1029 assert(!CDSConfig::module_patching_disables_cds(), "Cannot use CDS");
1030 }
1031 } else {
1032 // During dump time, this class was in a named module, but at run time, this class should be
1033 // in an unnamed module.
1034 visible = false;
1035 }
1036 } else {
1037 if (should_be_in_named_module) {
1038 // During dump time, this class was in an unnamed, but at run time, this class should be
1039 // in a named module.
1040 visible = false;
1041 } else {
1042 visible = true;
1043 }
1044 }
1045
1046 return visible;
1047 }
1048
1049 bool SystemDictionary::check_shared_class_super_type(InstanceKlass* klass, InstanceKlass* super_type,
1143 Handle protection_domain,
1144 const ClassFileStream *cfs,
1145 PackageEntry* pkg_entry,
1146 TRAPS) {
1147 assert(ik != nullptr, "sanity");
1148 assert(!ik->is_unshareable_info_restored(), "shared class can be restored only once");
1149 assert(Atomic::add(&ik->_shared_class_load_count, 1) == 1, "shared class loaded more than once");
1150 Symbol* class_name = ik->name();
1151
1152 if (!is_shared_class_visible(class_name, ik, pkg_entry, class_loader)) {
1153 ik->set_shared_loading_failed();
1154 return nullptr;
1155 }
1156
1157 bool check = check_shared_class_super_types(ik, class_loader, protection_domain, CHECK_NULL);
1158 if (!check) {
1159 ik->set_shared_loading_failed();
1160 return nullptr;
1161 }
1162
1163 if (ik->has_inline_type_fields()) {
1164 for (AllFieldStream fs(ik); !fs.done(); fs.next()) {
1165 if (fs.access_flags().is_static()) continue;
1166 Symbol* sig = fs.signature();
1167 if (fs.is_null_free_inline_type()) {
1168 // Pre-load inline class
1169 TempNewSymbol name = Signature::strip_envelope(sig);
1170 Klass* real_k = SystemDictionary::resolve_with_circularity_detection_or_fail(ik->name(), name,
1171 class_loader, protection_domain, false, CHECK_NULL);
1172 Klass* k = ik->get_inline_type_field_klass_or_null(fs.index());
1173 if (real_k != k) {
1174 // oops, the app has substituted a different version of k!
1175 return nullptr;
1176 }
1177 } else if (Signature::has_envelope(sig)) {
1178 TempNewSymbol name = Signature::strip_envelope(sig);
1179 if (name != ik->name() && ik->is_class_in_loadable_descriptors_attribute(name)) {
1180 Klass* real_k = SystemDictionary::resolve_with_circularity_detection_or_fail(ik->name(), name,
1181 class_loader, protection_domain, false, THREAD);
1182 if (HAS_PENDING_EXCEPTION) {
1183 CLEAR_PENDING_EXCEPTION;
1184 }
1185 Klass* k = ik->get_inline_type_field_klass_or_null(fs.index());
1186 if (real_k != k) {
1187 // oops, the app has substituted a different version of k!
1188 return nullptr;
1189 }
1190 }
1191 }
1192 }
1193 }
1194
1195 InstanceKlass* new_ik = nullptr;
1196 // CFLH check is skipped for VM hidden classes (see KlassFactory::create_from_stream).
1197 // It will be skipped for shared VM hidden lambda proxy classes.
1198 if (!SystemDictionaryShared::is_hidden_lambda_proxy(ik)) {
1199 new_ik = KlassFactory::check_shared_class_file_load_hook(
1200 ik, class_name, class_loader, protection_domain, cfs, CHECK_NULL);
1201 }
1202 if (new_ik != nullptr) {
1203 // The class is changed by CFLH. Return the new class. The shared class is
1204 // not used.
1205 return new_ik;
1206 }
1207
1208 // Adjust methods to recover missing data. They need addresses for
1209 // interpreter entry points and their default native method address
1210 // must be reset.
1211
1212 // Shared classes are all currently loaded by either the bootstrap or
1213 // internal parallel class loaders, so this will never cause a deadlock
1214 // on a custom class loader lock.
1215 // Since this class is already locked with parallel capable class
1216 // loaders, including the bootstrap loader via the placeholder table,
1217 // this lock is currently a nop.
1218
1219 ClassLoaderData* loader_data = class_loader_data(class_loader);
1220 {
1221 HandleMark hm(THREAD);
1222 Handle lockObject = get_loader_lock_or_null(class_loader);
1223 ObjectLocker ol(lockObject, THREAD);
1224 // prohibited package check assumes all classes loaded from archive call
1225 // restore_unshareable_info which calls ik->set_package()
1226 ik->restore_unshareable_info(loader_data, protection_domain, pkg_entry, CHECK_NULL);
1227 }
1228
1229 load_shared_class_misc(ik, loader_data);
1230
1231 return ik;
1232 }
1233
1234 void SystemDictionary::load_shared_class_misc(InstanceKlass* ik, ClassLoaderData* loader_data) {
1235 ik->print_class_load_logging(loader_data, nullptr, nullptr);
1236
1237 // For boot loader, ensure that GetSystemPackage knows that a class in this
1238 // package was loaded.
1239 if (loader_data->is_the_null_class_loader_data()) {
1240 s2 path_index = ik->shared_classpath_index();
1241 ik->set_classpath_index(path_index);
1242 }
1243
1244 // notify a class loaded from shared object
1245 ClassLoadingService::notify_class_loaded(ik, true /* shared class */);
1246 }
1247
1248 #endif // INCLUDE_CDS
1249
1250 InstanceKlass* SystemDictionary::load_instance_class_impl(Symbol* class_name, Handle class_loader, TRAPS) {
|