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);
936
937 InstanceKlass* SystemDictionary::resolve_from_stream(ClassFileStream* st,
938 Symbol* class_name,
939 Handle class_loader,
940 const ClassLoadInfo& cl_info,
941 TRAPS) {
942 if (cl_info.is_hidden()) {
943 return resolve_hidden_class_from_stream(st, class_name, class_loader, cl_info, CHECK_NULL);
944 } else {
945 return resolve_class_from_stream(st, class_name, class_loader, cl_info, CHECK_NULL);
946 }
947 }
948
949
950 #if INCLUDE_CDS
951 // Check if a shared class can be loaded by the specific classloader.
952 bool SystemDictionary::is_shared_class_visible(Symbol* class_name,
953 InstanceKlass* ik,
954 PackageEntry* pkg_entry,
955 Handle class_loader) {
956 assert(!ModuleEntryTable::javabase_moduleEntry()->is_patched(),
957 "Cannot use sharing if java.base is patched");
958
959 // (1) Check if we are loading into the same loader as in dump time.
960
961 if (ik->is_shared_boot_class()) {
962 if (class_loader() != nullptr) {
963 return false;
964 }
965 } else if (ik->is_shared_platform_class()) {
966 if (class_loader() != java_platform_loader()) {
967 return false;
968 }
969 } else if (ik->is_shared_app_class()) {
970 if (class_loader() != java_system_loader()) {
971 return false;
972 }
973 } else {
974 // ik was loaded by a custom loader during dump time
975 if (class_loader_data(class_loader)->is_builtin_class_loader_data()) {
976 return false;
977 } else {
1013
1014 if (pkg_entry == nullptr) {
1015 // We might have looked up pkg_entry before the module system was initialized.
1016 // Need to reload it now.
1017 TempNewSymbol pkg_name = ClassLoader::package_from_class_name(class_name);
1018 if (pkg_name != nullptr) {
1019 pkg_entry = class_loader_data(class_loader)->packages()->lookup_only(pkg_name);
1020 }
1021 }
1022
1023 ModuleEntry* mod_entry = (pkg_entry == nullptr) ? nullptr : pkg_entry->module();
1024 bool should_be_in_named_module = (mod_entry != nullptr && mod_entry->is_named());
1025 bool was_archived_from_named_module = scp_entry->in_named_module();
1026 bool visible;
1027
1028 if (was_archived_from_named_module) {
1029 if (should_be_in_named_module) {
1030 // Is the module loaded from the same location as during dump time?
1031 visible = mod_entry->shared_path_index() == scp_index;
1032 if (visible) {
1033 assert(!mod_entry->is_patched(), "cannot load archived classes for patched module");
1034 }
1035 } else {
1036 // During dump time, this class was in a named module, but at run time, this class should be
1037 // in an unnamed module.
1038 visible = false;
1039 }
1040 } else {
1041 if (should_be_in_named_module) {
1042 // During dump time, this class was in an unnamed, but at run time, this class should be
1043 // in a named module.
1044 visible = false;
1045 } else {
1046 visible = true;
1047 }
1048 }
1049
1050 return visible;
1051 }
1052
1053 bool SystemDictionary::check_shared_class_super_type(InstanceKlass* klass, InstanceKlass* super_type,
1147 Handle protection_domain,
1148 const ClassFileStream *cfs,
1149 PackageEntry* pkg_entry,
1150 TRAPS) {
1151 assert(ik != nullptr, "sanity");
1152 assert(!ik->is_unshareable_info_restored(), "shared class can be restored only once");
1153 assert(Atomic::add(&ik->_shared_class_load_count, 1) == 1, "shared class loaded more than once");
1154 Symbol* class_name = ik->name();
1155
1156 if (!is_shared_class_visible(class_name, ik, pkg_entry, class_loader)) {
1157 ik->set_shared_loading_failed();
1158 return nullptr;
1159 }
1160
1161 bool check = check_shared_class_super_types(ik, class_loader, protection_domain, CHECK_NULL);
1162 if (!check) {
1163 ik->set_shared_loading_failed();
1164 return nullptr;
1165 }
1166
1167 InstanceKlass* new_ik = nullptr;
1168 // CFLH check is skipped for VM hidden classes (see KlassFactory::create_from_stream).
1169 // It will be skipped for shared VM hidden lambda proxy classes.
1170 if (!SystemDictionaryShared::is_hidden_lambda_proxy(ik)) {
1171 new_ik = KlassFactory::check_shared_class_file_load_hook(
1172 ik, class_name, class_loader, protection_domain, cfs, CHECK_NULL);
1173 }
1174 if (new_ik != nullptr) {
1175 // The class is changed by CFLH. Return the new class. The shared class is
1176 // not used.
1177 return new_ik;
1178 }
1179
1180 // Adjust methods to recover missing data. They need addresses for
1181 // interpreter entry points and their default native method address
1182 // must be reset.
1183
1184 // Shared classes are all currently loaded by either the bootstrap or
1185 // internal parallel class loaders, so this will never cause a deadlock
1186 // on a custom class loader lock.
1187 // Since this class is already locked with parallel capable class
1188 // loaders, including the bootstrap loader via the placeholder table,
1189 // this lock is currently a nop.
1190
1191 ClassLoaderData* loader_data = class_loader_data(class_loader);
1192 {
1193 HandleMark hm(THREAD);
1194 Handle lockObject = get_loader_lock_or_null(class_loader);
1195 ObjectLocker ol(lockObject, THREAD);
1196 // prohibited package check assumes all classes loaded from archive call
1197 // restore_unshareable_info which calls ik->set_package()
1198 ik->restore_unshareable_info(loader_data, protection_domain, pkg_entry, CHECK_NULL);
1199 }
1200
1201 load_shared_class_misc(ik, loader_data);
1202 return ik;
1203 }
1204
1205 void SystemDictionary::load_shared_class_misc(InstanceKlass* ik, ClassLoaderData* loader_data) {
1206 ik->print_class_load_logging(loader_data, nullptr, nullptr);
1207
1208 // For boot loader, ensure that GetSystemPackage knows that a class in this
1209 // package was loaded.
1210 if (loader_data->is_the_null_class_loader_data()) {
1211 s2 path_index = ik->shared_classpath_index();
1212 ik->set_classpath_index(path_index);
1213 }
1214
1215 // notify a class loaded from shared object
1216 ClassLoadingService::notify_class_loaded(ik, true /* shared class */);
1217 }
1218
1219 #endif // INCLUDE_CDS
1220
1221 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);
940
941 InstanceKlass* SystemDictionary::resolve_from_stream(ClassFileStream* st,
942 Symbol* class_name,
943 Handle class_loader,
944 const ClassLoadInfo& cl_info,
945 TRAPS) {
946 if (cl_info.is_hidden()) {
947 return resolve_hidden_class_from_stream(st, class_name, class_loader, cl_info, CHECK_NULL);
948 } else {
949 return resolve_class_from_stream(st, class_name, class_loader, cl_info, CHECK_NULL);
950 }
951 }
952
953
954 #if INCLUDE_CDS
955 // Check if a shared class can be loaded by the specific classloader.
956 bool SystemDictionary::is_shared_class_visible(Symbol* class_name,
957 InstanceKlass* ik,
958 PackageEntry* pkg_entry,
959 Handle class_loader) {
960 assert(!CDSConfig::module_patching_disables_cds(), "Cannot use CDS");
961
962 // (1) Check if we are loading into the same loader as in dump time.
963
964 if (ik->is_shared_boot_class()) {
965 if (class_loader() != nullptr) {
966 return false;
967 }
968 } else if (ik->is_shared_platform_class()) {
969 if (class_loader() != java_platform_loader()) {
970 return false;
971 }
972 } else if (ik->is_shared_app_class()) {
973 if (class_loader() != java_system_loader()) {
974 return false;
975 }
976 } else {
977 // ik was loaded by a custom loader during dump time
978 if (class_loader_data(class_loader)->is_builtin_class_loader_data()) {
979 return false;
980 } else {
1016
1017 if (pkg_entry == nullptr) {
1018 // We might have looked up pkg_entry before the module system was initialized.
1019 // Need to reload it now.
1020 TempNewSymbol pkg_name = ClassLoader::package_from_class_name(class_name);
1021 if (pkg_name != nullptr) {
1022 pkg_entry = class_loader_data(class_loader)->packages()->lookup_only(pkg_name);
1023 }
1024 }
1025
1026 ModuleEntry* mod_entry = (pkg_entry == nullptr) ? nullptr : pkg_entry->module();
1027 bool should_be_in_named_module = (mod_entry != nullptr && mod_entry->is_named());
1028 bool was_archived_from_named_module = scp_entry->in_named_module();
1029 bool visible;
1030
1031 if (was_archived_from_named_module) {
1032 if (should_be_in_named_module) {
1033 // Is the module loaded from the same location as during dump time?
1034 visible = mod_entry->shared_path_index() == scp_index;
1035 if (visible) {
1036 assert(!CDSConfig::module_patching_disables_cds(), "Cannot use CDS");
1037 }
1038 } else {
1039 // During dump time, this class was in a named module, but at run time, this class should be
1040 // in an unnamed module.
1041 visible = false;
1042 }
1043 } else {
1044 if (should_be_in_named_module) {
1045 // During dump time, this class was in an unnamed, but at run time, this class should be
1046 // in a named module.
1047 visible = false;
1048 } else {
1049 visible = true;
1050 }
1051 }
1052
1053 return visible;
1054 }
1055
1056 bool SystemDictionary::check_shared_class_super_type(InstanceKlass* klass, InstanceKlass* super_type,
1150 Handle protection_domain,
1151 const ClassFileStream *cfs,
1152 PackageEntry* pkg_entry,
1153 TRAPS) {
1154 assert(ik != nullptr, "sanity");
1155 assert(!ik->is_unshareable_info_restored(), "shared class can be restored only once");
1156 assert(Atomic::add(&ik->_shared_class_load_count, 1) == 1, "shared class loaded more than once");
1157 Symbol* class_name = ik->name();
1158
1159 if (!is_shared_class_visible(class_name, ik, pkg_entry, class_loader)) {
1160 ik->set_shared_loading_failed();
1161 return nullptr;
1162 }
1163
1164 bool check = check_shared_class_super_types(ik, class_loader, protection_domain, CHECK_NULL);
1165 if (!check) {
1166 ik->set_shared_loading_failed();
1167 return nullptr;
1168 }
1169
1170 if (ik->has_inline_type_fields()) {
1171 for (AllFieldStream fs(ik); !fs.done(); fs.next()) {
1172 if (fs.access_flags().is_static()) continue;
1173 Symbol* sig = fs.signature();
1174 if (fs.is_null_free_inline_type()) {
1175 // Pre-load inline class
1176 TempNewSymbol name = Signature::strip_envelope(sig);
1177 Klass* real_k = SystemDictionary::resolve_with_circularity_detection_or_fail(ik->name(), name,
1178 class_loader, protection_domain, false, CHECK_NULL);
1179 Klass* k = ik->get_inline_type_field_klass_or_null(fs.index());
1180 if (real_k != k) {
1181 // oops, the app has substituted a different version of k!
1182 return nullptr;
1183 }
1184 } else if (Signature::has_envelope(sig)) {
1185 TempNewSymbol name = Signature::strip_envelope(sig);
1186 if (name != ik->name() && ik->is_class_in_loadable_descriptors_attribute(name)) {
1187 Klass* real_k = SystemDictionary::resolve_with_circularity_detection_or_fail(ik->name(), name,
1188 class_loader, protection_domain, false, THREAD);
1189 if (HAS_PENDING_EXCEPTION) {
1190 CLEAR_PENDING_EXCEPTION;
1191 }
1192 Klass* k = ik->get_inline_type_field_klass_or_null(fs.index());
1193 if (real_k != k) {
1194 // oops, the app has substituted a different version of k!
1195 return nullptr;
1196 }
1197 }
1198 }
1199 }
1200 }
1201
1202 InstanceKlass* new_ik = nullptr;
1203 // CFLH check is skipped for VM hidden classes (see KlassFactory::create_from_stream).
1204 // It will be skipped for shared VM hidden lambda proxy classes.
1205 if (!SystemDictionaryShared::is_hidden_lambda_proxy(ik)) {
1206 new_ik = KlassFactory::check_shared_class_file_load_hook(
1207 ik, class_name, class_loader, protection_domain, cfs, CHECK_NULL);
1208 }
1209 if (new_ik != nullptr) {
1210 // The class is changed by CFLH. Return the new class. The shared class is
1211 // not used.
1212 return new_ik;
1213 }
1214
1215 // Adjust methods to recover missing data. They need addresses for
1216 // interpreter entry points and their default native method address
1217 // must be reset.
1218
1219 // Shared classes are all currently loaded by either the bootstrap or
1220 // internal parallel class loaders, so this will never cause a deadlock
1221 // on a custom class loader lock.
1222 // Since this class is already locked with parallel capable class
1223 // loaders, including the bootstrap loader via the placeholder table,
1224 // this lock is currently a nop.
1225
1226 ClassLoaderData* loader_data = class_loader_data(class_loader);
1227 {
1228 HandleMark hm(THREAD);
1229 Handle lockObject = get_loader_lock_or_null(class_loader);
1230 ObjectLocker ol(lockObject, THREAD);
1231 // prohibited package check assumes all classes loaded from archive call
1232 // restore_unshareable_info which calls ik->set_package()
1233 ik->restore_unshareable_info(loader_data, protection_domain, pkg_entry, CHECK_NULL);
1234 }
1235
1236 load_shared_class_misc(ik, loader_data);
1237
1238 return ik;
1239 }
1240
1241 void SystemDictionary::load_shared_class_misc(InstanceKlass* ik, ClassLoaderData* loader_data) {
1242 ik->print_class_load_logging(loader_data, nullptr, nullptr);
1243
1244 // For boot loader, ensure that GetSystemPackage knows that a class in this
1245 // package was loaded.
1246 if (loader_data->is_the_null_class_loader_data()) {
1247 s2 path_index = ik->shared_classpath_index();
1248 ik->set_classpath_index(path_index);
1249 }
1250
1251 // notify a class loaded from shared object
1252 ClassLoadingService::notify_class_loaded(ik, true /* shared class */);
1253 }
1254
1255 #endif // INCLUDE_CDS
1256
1257 InstanceKlass* SystemDictionary::load_instance_class_impl(Symbol* class_name, Handle class_loader, TRAPS) {
|