@@ -354,11 +354,13 @@ void SystemDictionaryShared::check_exclusion_for_self_and_dependencies(InstanceK
354354 });
355355}
356356
357- // Returns true so the caller can do: return warn_excluded(".....");
358- bool SystemDictionaryShared::warn_excluded (InstanceKlass* k, const char * reason) {
357+ void SystemDictionaryShared::log_exclusion (InstanceKlass* k, const char * reason, bool is_warning) {
359358 ResourceMark rm;
360- aot_log_warning (aot)(" Skipping %s: %s" , k->name ()->as_C_string (), reason);
361- return true ;
359+ if (is_warning) {
360+ aot_log_warning (aot)(" Skipping %s: %s" , k->name ()->as_C_string (), reason);
361+ } else {
362+ aot_log_info (aot)(" Skipping %s: %s" , k->name ()->as_C_string (), reason);
363+ }
362364}
363365
364366bool SystemDictionaryShared::is_jfr_event_class (InstanceKlass *k) {
@@ -377,67 +379,78 @@ bool SystemDictionaryShared::is_early_klass(InstanceKlass* ik) {
377379}
378380
379381bool SystemDictionaryShared::check_self_exclusion (InstanceKlass* k) {
382+ bool log_warning = false ;
383+ const char * error = check_self_exclusion_helper (k, log_warning);
384+ if (error != nullptr ) {
385+ log_exclusion (k, error, log_warning);
386+ return true ; // Should be excluded
387+ } else {
388+ return false ; // Should not be excluded
389+ }
390+ }
391+
392+ const char * SystemDictionaryShared::check_self_exclusion_helper (InstanceKlass* k, bool & log_warning) {
380393 assert_lock_strong (DumpTimeTable_lock);
381394 if (CDSConfig::is_dumping_final_static_archive () && k->defined_by_other_loaders ()
382395 && k->in_aot_cache ()) {
383- return false ; // Do not exclude: unregistered classes are passed from preimage to final image.
396+ return nullptr ; // Do not exclude: unregistered classes are passed from preimage to final image.
384397 }
385398
386399 if (k->is_in_error_state ()) {
387- return warn_excluded (k, " In error state" );
400+ log_warning = true ;
401+ return " In error state" ;
388402 }
389403 if (k->is_scratch_class ()) {
390- return warn_excluded (k, " A scratch class" ) ;
404+ return " A scratch class" ;
391405 }
392406 if (!k->is_loaded ()) {
393- return warn_excluded (k, " Not in loaded state" ) ;
407+ return " Not in loaded state" ;
394408 }
395409 if (has_been_redefined (k)) {
396- return warn_excluded (k, " Has been redefined" ) ;
410+ return " Has been redefined" ;
397411 }
398412 if (!k->is_hidden () && k->shared_classpath_index () < 0 && is_builtin (k)) {
399413 if (k->name ()->starts_with (" java/lang/invoke/BoundMethodHandle$Species_" )) {
400414 // This class is dynamically generated by the JDK
401415 if (CDSConfig::is_dumping_method_handles ()) {
402416 k->set_shared_classpath_index (0 );
403417 } else {
404- ResourceMark rm;
405- aot_log_info (aot)(" Skipping %s because it is dynamically generated" , k->name ()->as_C_string ());
406- return true ; // exclude without warning
418+ return " dynamically generated" ;
407419 }
408420 } else {
409421 // These are classes loaded from unsupported locations (such as those loaded by JVMTI native
410422 // agent during dump time).
411- return warn_excluded (k, " Unsupported location" ) ;
423+ return " Unsupported location" ;
412424 }
413425 }
414426 if (k->signers () != nullptr ) {
415427 // We cannot include signed classes in the archive because the certificates
416428 // used during dump time may be different than those used during
417429 // runtime (due to expiration, etc).
418- return warn_excluded (k, " Signed JAR" ) ;
430+ return " Signed JAR" ;
419431 }
420432 if (is_jfr_event_class (k)) {
421433 // We cannot include JFR event classes because they need runtime-specific
422434 // instrumentation in order to work with -XX:FlightRecorderOptions:retransform=false.
423435 // There are only a small number of these classes, so it's not worthwhile to
424436 // support them and make CDS more complicated.
425- return warn_excluded (k, " JFR event class" ) ;
437+ return " JFR event class" ;
426438 }
427439
428440 if (!k->is_linked ()) {
429441 if (has_class_failed_verification (k)) {
430- return warn_excluded (k, " Failed verification" );
442+ log_warning = true ;
443+ return " Failed verification" ;
431444 } else if (CDSConfig::is_dumping_aot_linked_classes ()) {
432445 // Most loaded classes should have been speculatively linked by AOTMetaspace::link_class_for_cds().
433446 // Old classes may not be linked if CDSConfig::is_preserving_verification_constraints()==false.
434447 // An unlinked class may fail to verify in AOTLinkedClassBulkLoader::init_required_classes_for_loader(),
435448 // causing the JVM to fail at bootstrap.
436- return warn_excluded (k, " Unlinked class not supported by AOTClassLinking" ) ;
449+ return " Unlinked class not supported by AOTClassLinking" ;
437450 } else if (CDSConfig::is_dumping_preimage_static_archive ()) {
438451 // When dumping the final static archive, we will unconditionally load and link all
439452 // classes from the preimage. We don't want to get a VerifyError when linking this class.
440- return warn_excluded (k, " Unlinked class not supported by AOTConfiguration" ) ;
453+ return " Unlinked class not supported by AOTConfiguration" ;
441454 }
442455 } else {
443456 if (!k->can_be_verified_at_dumptime ()) {
@@ -447,17 +460,15 @@ bool SystemDictionaryShared::check_self_exclusion(InstanceKlass* k) {
447460 // won't work at runtime.
448461 // As a result, we cannot store this class. It must be loaded and fully verified
449462 // at runtime.
450- return warn_excluded (k, " Old class has been linked" ) ;
463+ return " Old class has been linked" ;
451464 }
452465 }
453466
454467 if (UnregisteredClasses::check_for_exclusion (k)) {
455- ResourceMark rm;
456- aot_log_info (aot)(" Skipping %s: used only when dumping CDS archive" , k->name ()->as_C_string ());
457- return true ;
468+ return " used only when dumping CDS archive" ;
458469 }
459470
460- return false ;
471+ return nullptr ;
461472}
462473
463474// Returns true if DumpTimeClassInfo::is_excluded() is true for at least one of k's exclusion dependencies.
@@ -511,7 +522,7 @@ bool SystemDictionaryShared::is_dependency_excluded(InstanceKlass* k, InstanceKl
511522 DumpTimeClassInfo* dependency_info = get_info_locked (dependency);
512523 if (dependency_info->is_excluded ()) {
513524 ResourceMark rm;
514- aot_log_warning (aot)(" Skipping %s: %s %s is excluded" , k->name ()->as_C_string (), type, dependency->name ()->as_C_string ());
525+ aot_log_info (aot)(" Skipping %s: %s %s is excluded" , k->name ()->as_C_string (), type, dependency->name ()->as_C_string ());
515526 return true ;
516527 }
517528 return false ;
@@ -838,7 +849,7 @@ class UnregisteredClassesDuplicationChecker : StackObj {
838849 InstanceKlass* k = _list.at (i);
839850 bool i_am_first = SystemDictionaryShared::add_unregistered_class (_thread, k);
840851 if (!i_am_first) {
841- SystemDictionaryShared::warn_excluded (k, " Duplicated unregistered class" );
852+ SystemDictionaryShared::log_exclusion (k, " Duplicated unregistered class" );
842853 SystemDictionaryShared::set_excluded_locked (k);
843854 }
844855 }
@@ -967,7 +978,7 @@ bool SystemDictionaryShared::has_class_failed_verification(InstanceKlass* ik) {
967978}
968979
969980void SystemDictionaryShared::set_from_class_file_load_hook (InstanceKlass* ik) {
970- warn_excluded (ik, " From ClassFileLoadHook" );
981+ log_exclusion (ik, " From ClassFileLoadHook" );
971982 set_excluded (ik);
972983}
973984
0 commit comments