< prev index next >

src/hotspot/share/classfile/systemDictionaryShared.cpp

Print this page

  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "cds/aotClassFilter.hpp"
  26 #include "cds/aotClassLocation.hpp"
  27 #include "cds/aotLogging.hpp"
  28 #include "cds/archiveBuilder.hpp"
  29 #include "cds/archiveUtils.hpp"
  30 #include "cds/cdsConfig.hpp"
  31 #include "cds/cdsProtectionDomain.hpp"
  32 #include "cds/classListParser.hpp"
  33 #include "cds/classListWriter.hpp"
  34 #include "cds/dumpTimeClassInfo.inline.hpp"
  35 #include "cds/dynamicArchive.hpp"
  36 #include "cds/filemap.hpp"
  37 #include "cds/heapShared.hpp"

  38 #include "cds/lambdaProxyClassDictionary.hpp"
  39 #include "cds/lambdaFormInvokers.inline.hpp"
  40 #include "cds/metaspaceShared.hpp"
  41 #include "cds/runTimeClassInfo.hpp"
  42 #include "cds/unregisteredClasses.hpp"
  43 #include "classfile/classFileStream.hpp"
  44 #include "classfile/classLoader.hpp"
  45 #include "classfile/classLoaderData.inline.hpp"
  46 #include "classfile/classLoaderDataGraph.hpp"
  47 #include "classfile/classLoaderExt.hpp"
  48 #include "classfile/dictionary.hpp"
  49 #include "classfile/javaClasses.hpp"
  50 #include "classfile/javaClasses.inline.hpp"
  51 #include "classfile/symbolTable.hpp"
  52 #include "classfile/systemDictionary.hpp"
  53 #include "classfile/systemDictionaryShared.hpp"
  54 #include "classfile/verificationType.hpp"
  55 #include "classfile/vmClasses.hpp"
  56 #include "classfile/vmSymbols.hpp"
  57 #include "jfr/jfrEvents.hpp"
  58 #include "logging/log.hpp"
  59 #include "logging/logStream.hpp"
  60 #include "memory/allocation.hpp"
  61 #include "memory/metadataFactory.hpp"
  62 #include "memory/metaspaceClosure.hpp"
  63 #include "memory/oopFactory.hpp"
  64 #include "memory/resourceArea.hpp"
  65 #include "memory/universe.hpp"
  66 #include "oops/compressedKlass.inline.hpp"
  67 #include "oops/instanceKlass.hpp"
  68 #include "oops/klass.inline.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/resourceHash.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 
  87 // Used by NoClassLoadingMark
  88 DEBUG_ONLY(bool SystemDictionaryShared::_class_loading_may_happen = true;)

  90 #ifdef ASSERT
  91 static void check_klass_after_loading(const Klass* k) {
  92 #ifdef _LP64
  93   if (k != nullptr && UseCompressedClassPointers && k->needs_narrow_id()) {
  94     CompressedKlassPointers::check_encodable(k);
  95   }
  96 #endif
  97 }
  98 #endif
  99 
 100 InstanceKlass* SystemDictionaryShared::load_shared_class_for_builtin_loader(
 101                  Symbol* class_name, Handle class_loader, TRAPS) {
 102   assert(CDSConfig::is_using_archive(), "must be");
 103   InstanceKlass* ik = find_builtin_class(class_name);
 104 
 105   if (ik != nullptr && !ik->shared_loading_failed()) {
 106     if ((SystemDictionary::is_system_class_loader(class_loader()) && ik->defined_by_app_loader())  ||
 107         (SystemDictionary::is_platform_class_loader(class_loader()) && ik->defined_by_platform_loader())) {
 108       SharedClassLoadingMark slm(THREAD, ik);
 109       PackageEntry* pkg_entry = CDSProtectionDomain::get_package_entry_from_class(ik, class_loader);
 110       Handle protection_domain =
 111         CDSProtectionDomain::init_security_info(class_loader, ik, pkg_entry, CHECK_NULL);



 112       return load_shared_class(ik, class_loader, protection_domain, nullptr, pkg_entry, THREAD);
 113     }
 114   }
 115   return nullptr;
 116 }
 117 
 118 // This function is called for loading only UNREGISTERED classes
 119 InstanceKlass* SystemDictionaryShared::lookup_from_stream(Symbol* class_name,
 120                                                           Handle class_loader,
 121                                                           Handle protection_domain,
 122                                                           const ClassFileStream* cfs,
 123                                                           TRAPS) {
 124   if (!CDSConfig::is_using_archive()) {
 125     return nullptr;
 126   }
 127   if (class_name == nullptr) {  // don't do this for hidden classes
 128     return nullptr;
 129   }
 130   if (class_loader.is_null() ||
 131       SystemDictionary::is_system_class_loader(class_loader()) ||

 277         aot_log_info(aot)("Skipping %s because it is dynamically generated", k->name()->as_C_string());
 278         return true; // exclude without warning
 279       }
 280     } else {
 281       // These are classes loaded from unsupported locations (such as those loaded by JVMTI native
 282       // agent during dump time).
 283       return warn_excluded(k, "Unsupported location");
 284     }
 285   }
 286   if (k->signers() != nullptr) {
 287     // We cannot include signed classes in the archive because the certificates
 288     // used during dump time may be different than those used during
 289     // runtime (due to expiration, etc).
 290     return warn_excluded(k, "Signed JAR");
 291   }
 292   if (is_jfr_event_class(k)) {
 293     // We cannot include JFR event classes because they need runtime-specific
 294     // instrumentation in order to work with -XX:FlightRecorderOptions:retransform=false.
 295     // There are only a small number of these classes, so it's not worthwhile to
 296     // support them and make CDS more complicated.
 297     return warn_excluded(k, "JFR event class");


 298   }
 299 
 300   if (!k->is_linked()) {
 301     if (has_class_failed_verification(k)) {
 302       return warn_excluded(k, "Failed verification");
 303     } else if (CDSConfig::is_dumping_aot_linked_classes()) {
 304       // Most loaded classes should have been speculatively linked by MetaspaceShared::link_class_for_cds().
 305       // However, we do not speculatively link old classes, as they are not recorded by
 306       // SystemDictionaryShared::record_linking_constraint(). As a result, such an unlinked
 307       // class may fail to verify in AOTLinkedClassBulkLoader::init_required_classes_for_loader(),
 308       // causing the JVM to fail at bootstrap.
 309       return warn_excluded(k, "Unlinked class not supported by AOTClassLinking");
 310     } else if (CDSConfig::is_dumping_preimage_static_archive()) {
 311       // When dumping the final static archive, we will unconditionally load and link all
 312       // classes from the preimage. We don't want to get a VerifyError when linking this class.
 313       return warn_excluded(k, "Unlinked class not supported by AOTConfiguration");
 314     }
 315   } else {
 316     if (!k->can_be_verified_at_dumptime()) {
 317       // We have an old class that has been linked (e.g., it's been executed during
 318       // dump time). This class has been verified using the old verifier, which
 319       // doesn't save the verification constraints, so check_verification_constraints()
 320       // won't work at runtime.
 321       // As a result, we cannot store this class. It must be loaded and fully verified
 322       // at runtime.
 323       return warn_excluded(k, "Old class has been linked");
 324     }
 325   }
 326 
 327   if (UnregisteredClasses::check_for_exclusion(k)) {
 328     ResourceMark rm;
 329     aot_log_info(aot)("Skipping %s: used only when dumping CDS archive", k->name()->as_C_string());
 330     return true;
 331   }
 332 
 333   InstanceKlass* super = k->java_super();
 334   if (super != nullptr && check_for_exclusion(super, nullptr)) {
 335     ResourceMark rm;
 336     aot_log_warning(aot)("Skipping %s: super class %s is excluded", k->name()->as_C_string(), super->name()->as_C_string());
 337     return true;
 338   }
 339 
 340   Array<InstanceKlass*>* interfaces = k->local_interfaces();
 341   int len = interfaces->length();
 342   for (int i = 0; i < len; i++) {
 343     InstanceKlass* intf = interfaces->at(i);
 344     if (check_for_exclusion(intf, nullptr)) {
 345       ResourceMark rm;
 346       aot_log_warning(aot)("Skipping %s: interface %s is excluded", k->name()->as_C_string(), intf->name()->as_C_string());
 347       return true;
 348     }
 349   }
 350 






 351   return false; // false == k should NOT be excluded
 352 }
 353 
 354 bool SystemDictionaryShared::is_builtin_loader(ClassLoaderData* loader_data) {
 355   oop class_loader = loader_data->class_loader();
 356   return (class_loader == nullptr ||
 357           SystemDictionary::is_system_class_loader(class_loader) ||
 358           SystemDictionary::is_platform_class_loader(class_loader));
 359 }
 360 
 361 bool SystemDictionaryShared::has_platform_or_app_classes() {
 362   if (FileMapInfo::current_info()->has_platform_or_app_classes()) {
 363     return true;
 364   }
 365   if (DynamicArchive::is_mapped() &&
 366       FileMapInfo::dynamic_info()->has_platform_or_app_classes()) {
 367     return true;
 368   }
 369   return false;
 370 }

 769 
 770   if (CDSConfig::is_dumping_lambdas_in_legacy_mode()) {
 771     LambdaProxyClassDictionary::dumptime_classes_do(it);
 772   }
 773 }
 774 
 775 // Called from VerificationType::is_reference_assignable_from() before performing the assignability check of
 776 //     T1 must be assignable from T2
 777 // Where:
 778 //     L is the class loader of <k>
 779 //     T1 is the type resolved by L using the name <name>
 780 //     T2 is the type resolved by L using the name <from_name>
 781 //
 782 // The meaning of (*skip_assignability_check):
 783 //     true:  is_reference_assignable_from() should SKIP the assignability check
 784 //     false: is_reference_assignable_from() should COMPLETE the assignability check
 785 void SystemDictionaryShared::add_verification_constraint(InstanceKlass* k, Symbol* name,
 786          Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object,
 787          bool* skip_assignability_check) {
 788   assert(CDSConfig::is_dumping_archive(), "sanity");











 789   DumpTimeClassInfo* info = get_info(k);
 790   info->add_verification_constraint(k, name, from_name, from_field_is_protected,
 791                                     from_is_array, from_is_object);
 792 
 793   if (CDSConfig::is_dumping_classic_static_archive() && !is_builtin(k)) {
 794     // This applies ONLY to the "classic" CDS static dump, which reads the list of
 795     // unregistered classes (those intended for custom class loaders) from the classlist
 796     // and loads them using jdk.internal.misc.CDS$UnregisteredClassLoader.
 797     //
 798     // When the classlist contains an unregistered class k, the supertypes of k are also
 799     // recorded in the classlist. However, the classlist does not contain information about
 800     // any class X that's not a supertype of k but is needed in the verification of k.
 801     // As a result, CDS$UnregisteredClassLoader will not know how to resolve X.
 802     //
 803     // Therefore, we tell the verifier to refrain from resolving X. Instead, X is recorded
 804     // (symbolically) in the verification constraints of k. In the production run,
 805     // when k is loaded, we will go through its verification constraints and resolve X to complete
 806     // the is_reference_assignable_from() checks.
 807     *skip_assignability_check = true;
 808   } else {

1229   print_shared_archive(st, false);
1230 }
1231 
1232 void SystemDictionaryShared::print_table_statistics(outputStream* st) {
1233   if (CDSConfig::is_using_archive()) {
1234     _static_archive.print_table_statistics("Static ", st, true);
1235     if (DynamicArchive::is_mapped()) {
1236       _dynamic_archive.print_table_statistics("Dynamic ", st, false);
1237     }
1238   }
1239 }
1240 
1241 bool SystemDictionaryShared::is_dumptime_table_empty() {
1242   assert_lock_strong(DumpTimeTable_lock);
1243   _dumptime_table->update_counts();
1244   if (_dumptime_table->count_of(true) == 0 && _dumptime_table->count_of(false) == 0){
1245     return true;
1246   }
1247   return false;
1248 }























































  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "cds/aotClassFilter.hpp"
  26 #include "cds/aotClassLocation.hpp"
  27 #include "cds/aotLogging.hpp"
  28 #include "cds/archiveBuilder.hpp"
  29 #include "cds/archiveUtils.hpp"
  30 #include "cds/cdsConfig.hpp"
  31 #include "cds/cdsProtectionDomain.hpp"
  32 #include "cds/classListParser.hpp"
  33 #include "cds/classListWriter.hpp"
  34 #include "cds/dumpTimeClassInfo.inline.hpp"
  35 #include "cds/dynamicArchive.hpp"
  36 #include "cds/filemap.hpp"
  37 #include "cds/heapShared.hpp"
  38 #include "cds/lambdaFormInvokers.inline.hpp"
  39 #include "cds/lambdaProxyClassDictionary.hpp"
  40 #include "cds/lambdaFormInvokers.inline.hpp"
  41 #include "cds/metaspaceShared.hpp"
  42 #include "cds/runTimeClassInfo.hpp"
  43 #include "cds/unregisteredClasses.hpp"
  44 #include "classfile/classFileStream.hpp"
  45 #include "classfile/classLoader.hpp"
  46 #include "classfile/classLoaderData.inline.hpp"
  47 #include "classfile/classLoaderDataGraph.hpp"
  48 #include "classfile/classLoaderExt.hpp"
  49 #include "classfile/dictionary.hpp"
  50 #include "classfile/javaClasses.hpp"
  51 #include "classfile/javaClasses.inline.hpp"
  52 #include "classfile/symbolTable.hpp"
  53 #include "classfile/systemDictionary.hpp"
  54 #include "classfile/systemDictionaryShared.hpp"
  55 #include "classfile/verificationType.hpp"
  56 #include "classfile/vmClasses.hpp"
  57 #include "classfile/vmSymbols.hpp"
  58 #include "jfr/jfrEvents.hpp"
  59 #include "logging/log.hpp"
  60 #include "logging/logStream.hpp"
  61 #include "memory/allocation.hpp"
  62 #include "memory/metadataFactory.hpp"
  63 #include "memory/metaspaceClosure.hpp"
  64 #include "memory/oopFactory.hpp"
  65 #include "memory/resourceArea.hpp"
  66 #include "memory/universe.hpp"
  67 #include "oops/compressedKlass.inline.hpp"
  68 #include "oops/instanceKlass.hpp"
  69 #include "oops/klass.inline.hpp"
  70 #include "oops/methodData.hpp"
  71 #include "oops/objArrayKlass.hpp"
  72 #include "oops/objArrayOop.inline.hpp"
  73 #include "oops/oop.inline.hpp"
  74 #include "oops/oopHandle.inline.hpp"
  75 #include "oops/typeArrayOop.inline.hpp"
  76 #include "runtime/arguments.hpp"
  77 #include "runtime/handles.inline.hpp"
  78 #include "runtime/java.hpp"
  79 #include "runtime/javaCalls.hpp"
  80 #include "runtime/mutexLocker.hpp"
  81 #include "utilities/resourceHash.hpp"
  82 #include "utilities/stringUtils.hpp"
  83 
  84 SystemDictionaryShared::ArchiveInfo SystemDictionaryShared::_static_archive;
  85 SystemDictionaryShared::ArchiveInfo SystemDictionaryShared::_dynamic_archive;
  86 
  87 DumpTimeSharedClassTable* SystemDictionaryShared::_dumptime_table = nullptr;
  88 
  89 // Used by NoClassLoadingMark
  90 DEBUG_ONLY(bool SystemDictionaryShared::_class_loading_may_happen = true;)

  92 #ifdef ASSERT
  93 static void check_klass_after_loading(const Klass* k) {
  94 #ifdef _LP64
  95   if (k != nullptr && UseCompressedClassPointers && k->needs_narrow_id()) {
  96     CompressedKlassPointers::check_encodable(k);
  97   }
  98 #endif
  99 }
 100 #endif
 101 
 102 InstanceKlass* SystemDictionaryShared::load_shared_class_for_builtin_loader(
 103                  Symbol* class_name, Handle class_loader, TRAPS) {
 104   assert(CDSConfig::is_using_archive(), "must be");
 105   InstanceKlass* ik = find_builtin_class(class_name);
 106 
 107   if (ik != nullptr && !ik->shared_loading_failed()) {
 108     if ((SystemDictionary::is_system_class_loader(class_loader()) && ik->defined_by_app_loader())  ||
 109         (SystemDictionary::is_platform_class_loader(class_loader()) && ik->defined_by_platform_loader())) {
 110       SharedClassLoadingMark slm(THREAD, ik);
 111       PackageEntry* pkg_entry = CDSProtectionDomain::get_package_entry_from_class(ik, class_loader);
 112       Handle protection_domain;
 113       if (!class_name->starts_with("jdk/proxy")) // java/lang/reflect/Proxy$ProxyBuilder defines the proxy classes with a null protection domain.
 114       {
 115         protection_domain = CDSProtectionDomain::init_security_info(class_loader, ik, pkg_entry, CHECK_NULL);
 116       }
 117       return load_shared_class(ik, class_loader, protection_domain, nullptr, pkg_entry, THREAD);
 118     }
 119   }
 120   return nullptr;
 121 }
 122 
 123 // This function is called for loading only UNREGISTERED classes
 124 InstanceKlass* SystemDictionaryShared::lookup_from_stream(Symbol* class_name,
 125                                                           Handle class_loader,
 126                                                           Handle protection_domain,
 127                                                           const ClassFileStream* cfs,
 128                                                           TRAPS) {
 129   if (!CDSConfig::is_using_archive()) {
 130     return nullptr;
 131   }
 132   if (class_name == nullptr) {  // don't do this for hidden classes
 133     return nullptr;
 134   }
 135   if (class_loader.is_null() ||
 136       SystemDictionary::is_system_class_loader(class_loader()) ||

 282         aot_log_info(aot)("Skipping %s because it is dynamically generated", k->name()->as_C_string());
 283         return true; // exclude without warning
 284       }
 285     } else {
 286       // These are classes loaded from unsupported locations (such as those loaded by JVMTI native
 287       // agent during dump time).
 288       return warn_excluded(k, "Unsupported location");
 289     }
 290   }
 291   if (k->signers() != nullptr) {
 292     // We cannot include signed classes in the archive because the certificates
 293     // used during dump time may be different than those used during
 294     // runtime (due to expiration, etc).
 295     return warn_excluded(k, "Signed JAR");
 296   }
 297   if (is_jfr_event_class(k)) {
 298     // We cannot include JFR event classes because they need runtime-specific
 299     // instrumentation in order to work with -XX:FlightRecorderOptions:retransform=false.
 300     // There are only a small number of these classes, so it's not worthwhile to
 301     // support them and make CDS more complicated.
 302     if (!CDSConfig::is_dumping_reflection_data()) { // FIXME: !!! HACK !!!
 303       return warn_excluded(k, "JFR event class");
 304     }
 305   }
 306 
 307   if (!k->is_linked()) {
 308     if (has_class_failed_verification(k)) {
 309       return warn_excluded(k, "Failed verification");
 310     } else if (CDSConfig::is_dumping_aot_linked_classes()) {
 311       // Most loaded classes should have been speculatively linked by MetaspaceShared::link_class_for_cds().
 312       // However, we do not speculatively link old classes, as they are not recorded by
 313       // SystemDictionaryShared::record_linking_constraint(). As a result, such an unlinked
 314       // class may fail to verify in AOTLinkedClassBulkLoader::init_required_classes_for_loader(),
 315       // causing the JVM to fail at bootstrap.
 316       return warn_excluded(k, "Unlinked class not supported by AOTClassLinking");
 317     } else if (CDSConfig::is_dumping_preimage_static_archive()) {
 318       // When dumping the final static archive, we will unconditionally load and link all
 319       // classes from the preimage. We don't want to get a VerifyError when linking this class.
 320       return warn_excluded(k, "Unlinked class not supported by AOTConfiguration");
 321     }
 322   } else {
 323     if (!k->can_be_verified_at_dumptime() && !CDSConfig::preserve_all_dumptime_verification_states(k)) {
 324       // We have an old class that has been linked (e.g., it's been executed during
 325       // dump time). This class has been verified using the old verifier, which
 326       // doesn't save the verification constraints, so check_verification_constraints()
 327       // won't work at runtime.
 328       // As a result, we cannot store this class. It must be loaded and fully verified
 329       // at runtime.
 330       return warn_excluded(k, "Old class has been linked");
 331     }
 332   }
 333 
 334   if (UnregisteredClasses::check_for_exclusion(k)) {
 335     ResourceMark rm;
 336     aot_log_info(aot)("Skipping %s: used only when dumping CDS archive", k->name()->as_C_string());
 337     return true;
 338   }
 339 
 340   InstanceKlass* super = k->java_super();
 341   if (super != nullptr && check_for_exclusion(super, nullptr)) {
 342     ResourceMark rm;
 343     aot_log_warning(aot)("Skipping %s: super class %s is excluded", k->name()->as_C_string(), super->name()->as_C_string());
 344     return true;
 345   }
 346 
 347   Array<InstanceKlass*>* interfaces = k->local_interfaces();
 348   int len = interfaces->length();
 349   for (int i = 0; i < len; i++) {
 350     InstanceKlass* intf = interfaces->at(i);
 351     if (check_for_exclusion(intf, nullptr)) {
 352       ResourceMark rm;
 353       aot_log_warning(aot)("Skipping %s: interface %s is excluded", k->name()->as_C_string(), intf->name()->as_C_string());
 354       return true;
 355     }
 356   }
 357 
 358   if (k->name()->equals("jdk/internal/misc/CDS$DummyForDynamicArchive") && !CDSConfig::is_dumping_dynamic_archive()) {
 359     ResourceMark rm;
 360     log_debug(cds)("Skipping %s: used only when dumping dynamic CDS archive", k->name()->as_C_string());
 361     return true;
 362   }
 363 
 364   return false; // false == k should NOT be excluded
 365 }
 366 
 367 bool SystemDictionaryShared::is_builtin_loader(ClassLoaderData* loader_data) {
 368   oop class_loader = loader_data->class_loader();
 369   return (class_loader == nullptr ||
 370           SystemDictionary::is_system_class_loader(class_loader) ||
 371           SystemDictionary::is_platform_class_loader(class_loader));
 372 }
 373 
 374 bool SystemDictionaryShared::has_platform_or_app_classes() {
 375   if (FileMapInfo::current_info()->has_platform_or_app_classes()) {
 376     return true;
 377   }
 378   if (DynamicArchive::is_mapped() &&
 379       FileMapInfo::dynamic_info()->has_platform_or_app_classes()) {
 380     return true;
 381   }
 382   return false;
 383 }

 782 
 783   if (CDSConfig::is_dumping_lambdas_in_legacy_mode()) {
 784     LambdaProxyClassDictionary::dumptime_classes_do(it);
 785   }
 786 }
 787 
 788 // Called from VerificationType::is_reference_assignable_from() before performing the assignability check of
 789 //     T1 must be assignable from T2
 790 // Where:
 791 //     L is the class loader of <k>
 792 //     T1 is the type resolved by L using the name <name>
 793 //     T2 is the type resolved by L using the name <from_name>
 794 //
 795 // The meaning of (*skip_assignability_check):
 796 //     true:  is_reference_assignable_from() should SKIP the assignability check
 797 //     false: is_reference_assignable_from() should COMPLETE the assignability check
 798 void SystemDictionaryShared::add_verification_constraint(InstanceKlass* k, Symbol* name,
 799          Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object,
 800          bool* skip_assignability_check) {
 801   assert(CDSConfig::is_dumping_archive(), "sanity");
 802   if (CDSConfig::is_dumping_dynamic_archive() && k->is_shared()) {
 803     // k is a new class in the static archive, but one of its supertypes is an old class, so k wasn't
 804     // verified during dump time. No need to record constraints as k won't be included in the dynamic archive.
 805     return;
 806   }
 807   if (CDSConfig::is_dumping_aot_linked_classes() && is_builtin(k)) {
 808     // There's no need to save verification constraints
 809     // TODO -- double check the logic before integrating into mainline!!
 810     return;
 811   }
 812 
 813   DumpTimeClassInfo* info = get_info(k);
 814   info->add_verification_constraint(k, name, from_name, from_field_is_protected,
 815                                     from_is_array, from_is_object);
 816 
 817   if (CDSConfig::is_dumping_classic_static_archive() && !is_builtin(k)) {
 818     // This applies ONLY to the "classic" CDS static dump, which reads the list of
 819     // unregistered classes (those intended for custom class loaders) from the classlist
 820     // and loads them using jdk.internal.misc.CDS$UnregisteredClassLoader.
 821     //
 822     // When the classlist contains an unregistered class k, the supertypes of k are also
 823     // recorded in the classlist. However, the classlist does not contain information about
 824     // any class X that's not a supertype of k but is needed in the verification of k.
 825     // As a result, CDS$UnregisteredClassLoader will not know how to resolve X.
 826     //
 827     // Therefore, we tell the verifier to refrain from resolving X. Instead, X is recorded
 828     // (symbolically) in the verification constraints of k. In the production run,
 829     // when k is loaded, we will go through its verification constraints and resolve X to complete
 830     // the is_reference_assignable_from() checks.
 831     *skip_assignability_check = true;
 832   } else {

1253   print_shared_archive(st, false);
1254 }
1255 
1256 void SystemDictionaryShared::print_table_statistics(outputStream* st) {
1257   if (CDSConfig::is_using_archive()) {
1258     _static_archive.print_table_statistics("Static ", st, true);
1259     if (DynamicArchive::is_mapped()) {
1260       _dynamic_archive.print_table_statistics("Dynamic ", st, false);
1261     }
1262   }
1263 }
1264 
1265 bool SystemDictionaryShared::is_dumptime_table_empty() {
1266   assert_lock_strong(DumpTimeTable_lock);
1267   _dumptime_table->update_counts();
1268   if (_dumptime_table->count_of(true) == 0 && _dumptime_table->count_of(false) == 0){
1269     return true;
1270   }
1271   return false;
1272 }
1273 
1274 void SystemDictionaryShared::create_loader_positive_lookup_cache(TRAPS) {
1275   GrowableArray<InstanceKlass*> shared_classes_list;
1276   {
1277     // With static dumping, we have only a single Java thread (see JVM_StartThread) so
1278     // no no other threads should be loading classes. Otherwise, the code below may miss some
1279     // classes that are loaded concurrently.
1280     assert(CDSConfig::is_dumping_static_archive(), "no other threads should be loading classes");
1281 
1282     MutexLocker ml(DumpTimeTable_lock, Mutex::_no_safepoint_check_flag);
1283     _dumptime_table->iterate_all_classes_in_builtin_loaders([&](InstanceKlass* k, DumpTimeClassInfo& info) {
1284         if (!k->is_hidden() && !check_for_exclusion(k, &info)) {
1285           shared_classes_list.append(k);
1286         }
1287       }
1288     );
1289   }
1290 
1291   InstanceKlass* ik = vmClasses::Class_klass();
1292   objArrayOop r = oopFactory::new_objArray(ik, shared_classes_list.length(), CHECK);
1293   objArrayHandle array_h(THREAD, r);
1294 
1295   for (int i = 0; i < shared_classes_list.length(); i++) {
1296     oop mirror = shared_classes_list.at(i)->java_mirror();
1297     Handle mirror_h(THREAD, mirror);
1298     array_h->obj_at_put(i, mirror_h());
1299   }
1300 
1301   TempNewSymbol method = SymbolTable::new_symbol("generatePositiveLookupCache");
1302   TempNewSymbol signature = SymbolTable::new_symbol("([Ljava/lang/Class;)V");
1303 
1304   JavaCallArguments args(Handle(THREAD, SystemDictionary::java_system_loader()));
1305   args.push_oop(array_h);
1306   JavaValue result(T_VOID);
1307   JavaCalls::call_virtual(&result,
1308                           vmClasses::jdk_internal_loader_ClassLoaders_AppClassLoader_klass(),
1309                           method,
1310                           signature,
1311                           &args,
1312                           CHECK);
1313 
1314   if (HAS_PENDING_EXCEPTION) {
1315     Handle exc_handle(THREAD, PENDING_EXCEPTION);
1316     CLEAR_PENDING_EXCEPTION;
1317     ResourceMark rm(THREAD);
1318 
1319     log_warning(cds)("Exception during AppClassLoader::generatePositiveLookupCache() call");
1320     LogStreamHandle(Debug, cds) log;
1321     if (log.is_enabled()) {
1322       java_lang_Throwable::print_stack_trace(exc_handle, &log);
1323     }
1324     return;
1325   }
1326 }
< prev index next >