48 #include "classfile/dictionary.hpp"
49 #include "classfile/javaClasses.inline.hpp"
50 #include "classfile/symbolTable.hpp"
51 #include "classfile/systemDictionary.hpp"
52 #include "classfile/systemDictionaryShared.hpp"
53 #include "classfile/verificationType.hpp"
54 #include "classfile/vmClasses.hpp"
55 #include "classfile/vmSymbols.hpp"
56 #include "jfr/jfrEvents.hpp"
57 #include "logging/log.hpp"
58 #include "logging/logStream.hpp"
59 #include "memory/allocation.hpp"
60 #include "memory/metadataFactory.hpp"
61 #include "memory/metaspaceClosure.hpp"
62 #include "memory/oopFactory.hpp"
63 #include "memory/resourceArea.hpp"
64 #include "memory/universe.hpp"
65 #include "oops/compressedKlass.inline.hpp"
66 #include "oops/instanceKlass.hpp"
67 #include "oops/klass.inline.hpp"
68 #include "oops/objArrayKlass.hpp"
69 #include "oops/objArrayOop.inline.hpp"
70 #include "oops/oop.inline.hpp"
71 #include "oops/oopHandle.inline.hpp"
72 #include "oops/typeArrayOop.inline.hpp"
73 #include "runtime/arguments.hpp"
74 #include "runtime/handles.inline.hpp"
75 #include "runtime/java.hpp"
76 #include "runtime/javaCalls.hpp"
77 #include "runtime/mutexLocker.hpp"
78 #include "utilities/hashTable.hpp"
79 #include "utilities/stringUtils.hpp"
80
81 SystemDictionaryShared::ArchiveInfo SystemDictionaryShared::_static_archive;
82 SystemDictionaryShared::ArchiveInfo SystemDictionaryShared::_dynamic_archive;
83
84 DumpTimeSharedClassTable* SystemDictionaryShared::_dumptime_table = nullptr;
85
86 // Used by NoClassLoadingMark
87 DEBUG_ONLY(bool SystemDictionaryShared::_class_loading_may_happen = true;)
88
89 #ifdef ASSERT
90 static void check_klass_after_loading(const Klass* k) {
91 #ifdef _LP64
92 if (k != nullptr && UseCompressedClassPointers) {
93 CompressedKlassPointers::check_encodable(k);
94 }
95 #endif
96 }
97 #endif
98
99 InstanceKlass* SystemDictionaryShared::load_shared_class_for_builtin_loader(
100 Symbol* class_name, Handle class_loader, TRAPS) {
101 assert(CDSConfig::is_using_archive(), "must be");
102 InstanceKlass* ik = find_builtin_class(class_name);
103
104 if (ik != nullptr && !ik->shared_loading_failed()) {
105 if ((SystemDictionary::is_system_class_loader(class_loader()) && ik->defined_by_app_loader()) ||
106 (SystemDictionary::is_platform_class_loader(class_loader()) && ik->defined_by_platform_loader())) {
107 SharedClassLoadingMark slm(THREAD, ik);
108 PackageEntry* pkg_entry = CDSProtectionDomain::get_package_entry_from_class(ik, class_loader);
109 Handle protection_domain =
110 CDSProtectionDomain::init_security_info(class_loader, ik, pkg_entry, CHECK_NULL);
111 return load_shared_class(ik, class_loader, protection_domain, nullptr, pkg_entry, THREAD);
112 }
113 }
114 return nullptr;
115 }
116
117 // This function is called for loading only UNREGISTERED classes
118 InstanceKlass* SystemDictionaryShared::lookup_from_stream(Symbol* class_name,
119 Handle class_loader,
120 Handle protection_domain,
121 const ClassFileStream* cfs,
122 TRAPS) {
123 if (!CDSConfig::is_using_archive()) {
124 return nullptr;
125 }
126 if (class_name == nullptr) { // don't do this for hidden classes
127 return nullptr;
128 }
129 if (class_loader.is_null() ||
130 SystemDictionary::is_system_class_loader(class_loader()) ||
843 // in both hierarchies, causing most of the classes to be excluded.
844 // We sort the classes by their loaders. This way we're likely to archive
845 // all classes in the one of the two hierarchies.
846 _list.sort(compare_by_loader);
847 for (int i = 0; i < _list.length(); i++) {
848 InstanceKlass* k = _list.at(i);
849 bool i_am_first = SystemDictionaryShared::add_unregistered_class(_thread, k);
850 if (!i_am_first) {
851 SystemDictionaryShared::log_exclusion(k, "Duplicated unregistered class");
852 SystemDictionaryShared::set_excluded_locked(k);
853 }
854 }
855 }
856 };
857
858 // Returns true if the class should be excluded. This can be called by
859 // AOTConstantPoolResolver before or after we enter the CDS safepoint.
860 // When called before the safepoint, we need to link the class so that
861 // it can be checked by should_be_excluded_impl().
862 bool SystemDictionaryShared::should_be_excluded(Klass* k) {
863 assert(CDSConfig::is_dumping_archive(), "sanity");
864 assert(CDSConfig::current_thread_is_vm_or_dumper(), "sanity");
865
866 if (CDSConfig::is_dumping_dynamic_archive() && AOTMetaspace::in_aot_cache(k)) {
867 // We have reached a super type that's already in the base archive. Treat it
868 // as "not excluded".
869 return false;
870 }
871
872 if (k->is_objArray_klass()) {
873 return should_be_excluded(ObjArrayKlass::cast(k)->bottom_klass());
874 } else if (!k->is_instance_klass()) {
875 assert(k->is_typeArray_klass(), "must be");
876 return false;
877 } else {
878 InstanceKlass* ik = InstanceKlass::cast(k);
879
880 if (!SafepointSynchronize::is_at_safepoint()) {
881 if (!ik->is_linked()) {
882 // should_be_excluded_impl() below doesn't link unlinked classes. We come
883 // here only when we are trying to aot-link constant pool entries, so
884 // we'd better link the class.
885 JavaThread* THREAD = JavaThread::current();
886 ik->link_class(THREAD);
887 if (HAS_PENDING_EXCEPTION) {
888 CLEAR_PENDING_EXCEPTION;
889 return true; // linking failed -- let's exclude it
890 }
891
892 // Also link any classes that were loaded for the verification of ik or its supertypes.
893 // Otherwise we might miss the verification constraints of those classes.
894 AOTMetaspace::link_all_loaded_classes(THREAD);
895 }
896
897 MutexLocker ml(DumpTimeTable_lock, Mutex::_no_safepoint_check_flag);
898 DumpTimeClassInfo* p = get_info_locked(ik);
899 if (p->is_excluded()) {
924
925 void SystemDictionaryShared::finish_exclusion_checks() {
926 assert_at_safepoint();
927 if (CDSConfig::is_dumping_dynamic_archive() || CDSConfig::is_dumping_preimage_static_archive()) {
928 // Do this first -- if a base class is excluded due to duplication,
929 // all of its subclasses will also be excluded.
930 ResourceMark rm;
931 UnregisteredClassesDuplicationChecker dup_checker;
932 _dumptime_table->iterate_all_live_classes(&dup_checker);
933 dup_checker.mark_duplicated_classes();
934 }
935
936 _dumptime_table->iterate_all_live_classes([&] (InstanceKlass* k, DumpTimeClassInfo& info) {
937 SystemDictionaryShared::should_be_excluded_impl(k, &info);
938 });
939
940 _dumptime_table->update_counts();
941 if (CDSConfig::is_dumping_lambdas_in_legacy_mode()) {
942 LambdaProxyClassDictionary::cleanup_dumptime_table();
943 }
944 }
945
946 bool SystemDictionaryShared::is_excluded_class(InstanceKlass* k) {
947 assert(!class_loading_may_happen(), "class loading must be disabled");
948 assert_lock_strong(DumpTimeTable_lock);
949 assert(CDSConfig::is_dumping_archive(), "sanity");
950 DumpTimeClassInfo* p = get_info_locked(k);
951 return p->is_excluded();
952 }
953
954 void SystemDictionaryShared::set_excluded_locked(InstanceKlass* k) {
955 assert_lock_strong(DumpTimeTable_lock);
956 assert(CDSConfig::is_dumping_archive(), "sanity");
957 DumpTimeClassInfo* info = get_info_locked(k);
958 info->set_excluded();
959 }
960
961 void SystemDictionaryShared::set_excluded(InstanceKlass* k) {
962 assert(CDSConfig::is_dumping_archive(), "sanity");
963 DumpTimeClassInfo* info = get_info(k);
996
997 if (CDSConfig::is_dumping_lambdas_in_legacy_mode()) {
998 LambdaProxyClassDictionary::dumptime_classes_do(it);
999 }
1000 }
1001
1002 // Called from VerificationType::is_reference_assignable_from() before performing the assignability check of
1003 // T1 must be assignable from T2
1004 // Where:
1005 // L is the class loader of <k>
1006 // T1 is the type resolved by L using the name <name>
1007 // T2 is the type resolved by L using the name <from_name>
1008 //
1009 // The meaning of (*skip_assignability_check):
1010 // true: is_reference_assignable_from() should SKIP the assignability check
1011 // false: is_reference_assignable_from() should COMPLETE the assignability check
1012 void SystemDictionaryShared::add_verification_constraint(InstanceKlass* k, Symbol* name,
1013 Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object,
1014 bool* skip_assignability_check) {
1015 assert(CDSConfig::is_dumping_archive(), "sanity");
1016 DumpTimeClassInfo* info = get_info(k);
1017 info->add_verification_constraint(name, from_name, from_field_is_protected,
1018 from_is_array, from_is_object);
1019
1020 if (CDSConfig::is_dumping_classic_static_archive() && !is_builtin(k)) {
1021 // This applies ONLY to the "classic" CDS static dump, which reads the list of
1022 // unregistered classes (those intended for custom class loaders) from the classlist
1023 // and loads them using jdk.internal.misc.CDS$UnregisteredClassLoader.
1024 //
1025 // When the classlist contains an unregistered class k, the supertypes of k are also
1026 // recorded in the classlist. However, the classlist does not contain information about
1027 // any class X that's not a supertype of k but is needed in the verification of k.
1028 // As a result, CDS$UnregisteredClassLoader will not know how to resolve X.
1029 //
1030 // Therefore, we tell the verifier to refrain from resolving X. Instead, X is recorded
1031 // (symbolically) in the verification constraints of k. In the production run,
1032 // when k is loaded, we will go through its verification constraints and resolve X to complete
1033 // the is_reference_assignable_from() checks.
1034 *skip_assignability_check = true;
1035 } else {
1478 print_shared_archive(st, false);
1479 }
1480
1481 void SystemDictionaryShared::print_table_statistics(outputStream* st) {
1482 if (CDSConfig::is_using_archive()) {
1483 _static_archive.print_table_statistics("Static ", st, true);
1484 if (DynamicArchive::is_mapped()) {
1485 _dynamic_archive.print_table_statistics("Dynamic ", st, false);
1486 }
1487 }
1488 }
1489
1490 bool SystemDictionaryShared::is_dumptime_table_empty() {
1491 assert_lock_strong(DumpTimeTable_lock);
1492 _dumptime_table->update_counts();
1493 if (_dumptime_table->count_of(true) == 0 && _dumptime_table->count_of(false) == 0){
1494 return true;
1495 }
1496 return false;
1497 }
|
48 #include "classfile/dictionary.hpp"
49 #include "classfile/javaClasses.inline.hpp"
50 #include "classfile/symbolTable.hpp"
51 #include "classfile/systemDictionary.hpp"
52 #include "classfile/systemDictionaryShared.hpp"
53 #include "classfile/verificationType.hpp"
54 #include "classfile/vmClasses.hpp"
55 #include "classfile/vmSymbols.hpp"
56 #include "jfr/jfrEvents.hpp"
57 #include "logging/log.hpp"
58 #include "logging/logStream.hpp"
59 #include "memory/allocation.hpp"
60 #include "memory/metadataFactory.hpp"
61 #include "memory/metaspaceClosure.hpp"
62 #include "memory/oopFactory.hpp"
63 #include "memory/resourceArea.hpp"
64 #include "memory/universe.hpp"
65 #include "oops/compressedKlass.inline.hpp"
66 #include "oops/instanceKlass.hpp"
67 #include "oops/klass.inline.hpp"
68 #include "oops/methodData.hpp"
69 #include "oops/objArrayKlass.hpp"
70 #include "oops/objArrayOop.inline.hpp"
71 #include "oops/oop.inline.hpp"
72 #include "oops/oopHandle.inline.hpp"
73 #include "oops/typeArrayOop.inline.hpp"
74 #include "runtime/arguments.hpp"
75 #include "runtime/handles.inline.hpp"
76 #include "runtime/java.hpp"
77 #include "runtime/javaCalls.hpp"
78 #include "runtime/mutexLocker.hpp"
79 #include "utilities/hashTable.hpp"
80 #include "utilities/stringUtils.hpp"
81
82 SystemDictionaryShared::ArchiveInfo SystemDictionaryShared::_static_archive;
83 SystemDictionaryShared::ArchiveInfo SystemDictionaryShared::_dynamic_archive;
84
85 DumpTimeSharedClassTable* SystemDictionaryShared::_dumptime_table = nullptr;
86 bool SystemDictionaryShared::_finished_exclusion_checks = false;
87
88 // Used by NoClassLoadingMark
89 DEBUG_ONLY(bool SystemDictionaryShared::_class_loading_may_happen = true;)
90
91 #ifdef ASSERT
92 static void check_klass_after_loading(const Klass* k) {
93 #ifdef _LP64
94 if (k != nullptr && UseCompressedClassPointers) {
95 CompressedKlassPointers::check_encodable(k);
96 }
97 #endif
98 }
99 #endif
100
101 InstanceKlass* SystemDictionaryShared::load_shared_class_for_builtin_loader(
102 Symbol* class_name, Handle class_loader, TRAPS) {
103 assert(CDSConfig::is_using_archive(), "must be");
104 InstanceKlass* ik = find_builtin_class(class_name);
105
106 if (ik != nullptr && !ik->shared_loading_failed()) {
107 if ((SystemDictionary::is_system_class_loader(class_loader()) && ik->defined_by_app_loader()) ||
108 (SystemDictionary::is_platform_class_loader(class_loader()) && ik->defined_by_platform_loader())) {
109 SharedClassLoadingMark slm(THREAD, ik);
110 PackageEntry* pkg_entry = CDSProtectionDomain::get_package_entry_from_class(ik, class_loader);
111 Handle protection_domain;
112 if (!class_name->starts_with("jdk/proxy")) // java/lang/reflect/Proxy$ProxyBuilder defines the proxy classes with a null protection domain.
113 {
114 protection_domain = CDSProtectionDomain::init_security_info(class_loader, ik, pkg_entry, CHECK_NULL);
115 }
116 return load_shared_class(ik, class_loader, protection_domain, nullptr, pkg_entry, THREAD);
117 }
118 }
119 return nullptr;
120 }
121
122 // This function is called for loading only UNREGISTERED classes
123 InstanceKlass* SystemDictionaryShared::lookup_from_stream(Symbol* class_name,
124 Handle class_loader,
125 Handle protection_domain,
126 const ClassFileStream* cfs,
127 TRAPS) {
128 if (!CDSConfig::is_using_archive()) {
129 return nullptr;
130 }
131 if (class_name == nullptr) { // don't do this for hidden classes
132 return nullptr;
133 }
134 if (class_loader.is_null() ||
135 SystemDictionary::is_system_class_loader(class_loader()) ||
848 // in both hierarchies, causing most of the classes to be excluded.
849 // We sort the classes by their loaders. This way we're likely to archive
850 // all classes in the one of the two hierarchies.
851 _list.sort(compare_by_loader);
852 for (int i = 0; i < _list.length(); i++) {
853 InstanceKlass* k = _list.at(i);
854 bool i_am_first = SystemDictionaryShared::add_unregistered_class(_thread, k);
855 if (!i_am_first) {
856 SystemDictionaryShared::log_exclusion(k, "Duplicated unregistered class");
857 SystemDictionaryShared::set_excluded_locked(k);
858 }
859 }
860 }
861 };
862
863 // Returns true if the class should be excluded. This can be called by
864 // AOTConstantPoolResolver before or after we enter the CDS safepoint.
865 // When called before the safepoint, we need to link the class so that
866 // it can be checked by should_be_excluded_impl().
867 bool SystemDictionaryShared::should_be_excluded(Klass* k) {
868 if (CDSConfig::is_dumping_dynamic_archive() && AOTMetaspace::in_aot_cache(k)) {
869 // We have reached a super type that's already in the base archive. Treat it
870 // as "not excluded".
871 return false;
872 }
873
874 if (k->is_objArray_klass()) {
875 return should_be_excluded(ObjArrayKlass::cast(k)->bottom_klass());
876 } else if (!k->is_instance_klass()) {
877 assert(k->is_typeArray_klass(), "must be");
878 return false;
879 } else {
880 InstanceKlass* ik = InstanceKlass::cast(k);
881
882 if (CDSConfig::is_dumping_final_static_archive() && _finished_exclusion_checks &&
883 !SafepointSynchronize::is_at_safepoint()) {
884 // This is called from the AOT compiler.
885 MutexLocker ml(DumpTimeTable_lock, Mutex::_no_safepoint_check_flag);
886 DumpTimeClassInfo* p = get_info_locked(ik);
887 if (p->is_excluded()) {
888 return true;
889 } else if (!p->has_checked_exclusion()) {
890 // This is a class that was loaded after we exited the AOT safepoint. This
891 // class is not in the AOT cache, so it must be considered as "excluded"
892 return true;
893 } else {
894 return false;
895 }
896 }
897
898 assert(CDSConfig::is_dumping_archive(), "sanity");
899 assert(CDSConfig::current_thread_is_vm_or_dumper(), "sanity");
900
901 if (!SafepointSynchronize::is_at_safepoint()) {
902 if (!ik->is_linked()) {
903 // should_be_excluded_impl() below doesn't link unlinked classes. We come
904 // here only when we are trying to aot-link constant pool entries, so
905 // we'd better link the class.
906 JavaThread* THREAD = JavaThread::current();
907 ik->link_class(THREAD);
908 if (HAS_PENDING_EXCEPTION) {
909 CLEAR_PENDING_EXCEPTION;
910 return true; // linking failed -- let's exclude it
911 }
912
913 // Also link any classes that were loaded for the verification of ik or its supertypes.
914 // Otherwise we might miss the verification constraints of those classes.
915 AOTMetaspace::link_all_loaded_classes(THREAD);
916 }
917
918 MutexLocker ml(DumpTimeTable_lock, Mutex::_no_safepoint_check_flag);
919 DumpTimeClassInfo* p = get_info_locked(ik);
920 if (p->is_excluded()) {
945
946 void SystemDictionaryShared::finish_exclusion_checks() {
947 assert_at_safepoint();
948 if (CDSConfig::is_dumping_dynamic_archive() || CDSConfig::is_dumping_preimage_static_archive()) {
949 // Do this first -- if a base class is excluded due to duplication,
950 // all of its subclasses will also be excluded.
951 ResourceMark rm;
952 UnregisteredClassesDuplicationChecker dup_checker;
953 _dumptime_table->iterate_all_live_classes(&dup_checker);
954 dup_checker.mark_duplicated_classes();
955 }
956
957 _dumptime_table->iterate_all_live_classes([&] (InstanceKlass* k, DumpTimeClassInfo& info) {
958 SystemDictionaryShared::should_be_excluded_impl(k, &info);
959 });
960
961 _dumptime_table->update_counts();
962 if (CDSConfig::is_dumping_lambdas_in_legacy_mode()) {
963 LambdaProxyClassDictionary::cleanup_dumptime_table();
964 }
965 _finished_exclusion_checks = true;
966 }
967
968 bool SystemDictionaryShared::is_excluded_class(InstanceKlass* k) {
969 assert(!class_loading_may_happen(), "class loading must be disabled");
970 assert_lock_strong(DumpTimeTable_lock);
971 assert(CDSConfig::is_dumping_archive(), "sanity");
972 DumpTimeClassInfo* p = get_info_locked(k);
973 return p->is_excluded();
974 }
975
976 void SystemDictionaryShared::set_excluded_locked(InstanceKlass* k) {
977 assert_lock_strong(DumpTimeTable_lock);
978 assert(CDSConfig::is_dumping_archive(), "sanity");
979 DumpTimeClassInfo* info = get_info_locked(k);
980 info->set_excluded();
981 }
982
983 void SystemDictionaryShared::set_excluded(InstanceKlass* k) {
984 assert(CDSConfig::is_dumping_archive(), "sanity");
985 DumpTimeClassInfo* info = get_info(k);
1018
1019 if (CDSConfig::is_dumping_lambdas_in_legacy_mode()) {
1020 LambdaProxyClassDictionary::dumptime_classes_do(it);
1021 }
1022 }
1023
1024 // Called from VerificationType::is_reference_assignable_from() before performing the assignability check of
1025 // T1 must be assignable from T2
1026 // Where:
1027 // L is the class loader of <k>
1028 // T1 is the type resolved by L using the name <name>
1029 // T2 is the type resolved by L using the name <from_name>
1030 //
1031 // The meaning of (*skip_assignability_check):
1032 // true: is_reference_assignable_from() should SKIP the assignability check
1033 // false: is_reference_assignable_from() should COMPLETE the assignability check
1034 void SystemDictionaryShared::add_verification_constraint(InstanceKlass* k, Symbol* name,
1035 Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object,
1036 bool* skip_assignability_check) {
1037 assert(CDSConfig::is_dumping_archive(), "sanity");
1038 if (CDSConfig::is_dumping_dynamic_archive() && k->in_aot_cache()) {
1039 // k is a new class in the static archive, but one of its supertypes is an old class, so k wasn't
1040 // verified during dump time. No need to record constraints as k won't be included in the dynamic archive.
1041 return;
1042 }
1043 if (CDSConfig::is_dumping_aot_linked_classes() && is_builtin(k)) {
1044 // There's no need to save verification constraints
1045 // TODO -- double check the logic before integrating into mainline!!
1046 return;
1047 }
1048
1049 DumpTimeClassInfo* info = get_info(k);
1050 info->add_verification_constraint(name, from_name, from_field_is_protected,
1051 from_is_array, from_is_object);
1052
1053 if (CDSConfig::is_dumping_classic_static_archive() && !is_builtin(k)) {
1054 // This applies ONLY to the "classic" CDS static dump, which reads the list of
1055 // unregistered classes (those intended for custom class loaders) from the classlist
1056 // and loads them using jdk.internal.misc.CDS$UnregisteredClassLoader.
1057 //
1058 // When the classlist contains an unregistered class k, the supertypes of k are also
1059 // recorded in the classlist. However, the classlist does not contain information about
1060 // any class X that's not a supertype of k but is needed in the verification of k.
1061 // As a result, CDS$UnregisteredClassLoader will not know how to resolve X.
1062 //
1063 // Therefore, we tell the verifier to refrain from resolving X. Instead, X is recorded
1064 // (symbolically) in the verification constraints of k. In the production run,
1065 // when k is loaded, we will go through its verification constraints and resolve X to complete
1066 // the is_reference_assignable_from() checks.
1067 *skip_assignability_check = true;
1068 } else {
1511 print_shared_archive(st, false);
1512 }
1513
1514 void SystemDictionaryShared::print_table_statistics(outputStream* st) {
1515 if (CDSConfig::is_using_archive()) {
1516 _static_archive.print_table_statistics("Static ", st, true);
1517 if (DynamicArchive::is_mapped()) {
1518 _dynamic_archive.print_table_statistics("Dynamic ", st, false);
1519 }
1520 }
1521 }
1522
1523 bool SystemDictionaryShared::is_dumptime_table_empty() {
1524 assert_lock_strong(DumpTimeTable_lock);
1525 _dumptime_table->update_counts();
1526 if (_dumptime_table->count_of(true) == 0 && _dumptime_table->count_of(false) == 0){
1527 return true;
1528 }
1529 return false;
1530 }
1531
1532 void SystemDictionaryShared::create_loader_positive_lookup_cache(TRAPS) {
1533 GrowableArray<InstanceKlass*> shared_classes_list;
1534 {
1535 // With static dumping, we have only a single Java thread (see JVM_StartThread) so
1536 // no no other threads should be loading classes. Otherwise, the code below may miss some
1537 // classes that are loaded concurrently.
1538 assert(CDSConfig::is_dumping_static_archive(), "no other threads should be loading classes");
1539
1540 MutexLocker ml(DumpTimeTable_lock, Mutex::_no_safepoint_check_flag);
1541 _dumptime_table->iterate_all_classes_in_builtin_loaders([&](InstanceKlass* k, DumpTimeClassInfo& info) {
1542 // FIXME -- this may not be correct before SystemDictionaryShared::finish_exclusion_checks()
1543 if (!k->is_hidden() && info.has_checked_exclusion() && !info.is_excluded()) {
1544 shared_classes_list.append(k);
1545 }
1546 }
1547 );
1548 }
1549
1550 InstanceKlass* ik = vmClasses::Class_klass();
1551 objArrayOop r = oopFactory::new_objArray(ik, shared_classes_list.length(), CHECK);
1552 objArrayHandle array_h(THREAD, r);
1553
1554 for (int i = 0; i < shared_classes_list.length(); i++) {
1555 oop mirror = shared_classes_list.at(i)->java_mirror();
1556 Handle mirror_h(THREAD, mirror);
1557 array_h->obj_at_put(i, mirror_h());
1558 }
1559
1560 TempNewSymbol method = SymbolTable::new_symbol("generatePositiveLookupCache");
1561 TempNewSymbol signature = SymbolTable::new_symbol("([Ljava/lang/Class;)V");
1562
1563 JavaCallArguments args(Handle(THREAD, SystemDictionary::java_system_loader()));
1564 args.push_oop(array_h);
1565 JavaValue result(T_VOID);
1566 JavaCalls::call_virtual(&result,
1567 vmClasses::jdk_internal_loader_ClassLoaders_AppClassLoader_klass(),
1568 method,
1569 signature,
1570 &args,
1571 CHECK);
1572
1573 if (HAS_PENDING_EXCEPTION) {
1574 Handle exc_handle(THREAD, PENDING_EXCEPTION);
1575 CLEAR_PENDING_EXCEPTION;
1576 ResourceMark rm(THREAD);
1577
1578 log_warning(cds)("Exception during AppClassLoader::generatePositiveLookupCache() call");
1579 LogStreamHandle(Debug, cds) log;
1580 if (log.is_enabled()) {
1581 java_lang_Throwable::print_stack_trace(exc_handle, &log);
1582 }
1583 return;
1584 }
1585 }
|