Skip to content

Commit 52e7778

Browse files
committed
8367910: Reduce warnings about unsupported classes in AOT cache creation
Reviewed-by: dholmes, kvn, shade
1 parent 3c9fd76 commit 52e7778

File tree

8 files changed

+45
-32
lines changed

8 files changed

+45
-32
lines changed

src/hotspot/share/cds/dumpTimeClassInfo.inline.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void DumpTimeSharedClassTable::iterate_all_live_classes(Function function) const
5353
assert(k->is_loader_alive(), "must not change");
5454
} else {
5555
if (!SystemDictionaryShared::is_excluded_class(k)) {
56-
SystemDictionaryShared::warn_excluded(k, "Class loader not alive");
56+
SystemDictionaryShared::log_exclusion(k, "Class loader not alive");
5757
SystemDictionaryShared::set_excluded_locked(k);
5858
}
5959
}

src/hotspot/share/classfile/systemDictionaryShared.cpp

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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

364366
bool SystemDictionaryShared::is_jfr_event_class(InstanceKlass *k) {
@@ -377,67 +379,78 @@ bool SystemDictionaryShared::is_early_klass(InstanceKlass* ik) {
377379
}
378380

379381
bool 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

969980
void 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

src/hotspot/share/classfile/systemDictionaryShared.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ class SystemDictionaryShared: public SystemDictionary {
180180
// exclusion checks
181181
static void check_exclusion_for_self_and_dependencies(InstanceKlass *k);
182182
static bool check_self_exclusion(InstanceKlass* k);
183+
static const char* check_self_exclusion_helper(InstanceKlass* k, bool& log_warning);
183184
static bool check_dependencies_exclusion(InstanceKlass* k, DumpTimeClassInfo* info);
184185
static bool check_verification_constraint_exclusion(InstanceKlass* k, Symbol* constraint_class_name);
185186
static bool is_dependency_excluded(InstanceKlass* k, InstanceKlass* dependency, const char* type);
@@ -277,7 +278,7 @@ class SystemDictionaryShared: public SystemDictionary {
277278
static void set_excluded(InstanceKlass* k);
278279
static void set_excluded_locked(InstanceKlass* k);
279280
static void set_from_class_file_load_hook(InstanceKlass* k) NOT_CDS_RETURN;
280-
static bool warn_excluded(InstanceKlass* k, const char* reason);
281+
static void log_exclusion(InstanceKlass* k, const char* reason, bool is_warning = false);
281282
static void dumptime_classes_do(class MetaspaceClosure* it);
282283
static void write_to_archive(bool is_static_archive = true);
283284
static void serialize_dictionary_headers(class SerializeClosure* soc,

src/hotspot/share/classfile/verifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ bool Verifier::verify(InstanceKlass* klass, bool should_verify_class, TRAPS) {
237237
// Exclude any classes that are verified with the old verifier, as the old verifier
238238
// doesn't call SystemDictionaryShared::add_verification_constraint()
239239
if (CDSConfig::is_dumping_archive()) {
240-
SystemDictionaryShared::warn_excluded(klass, "Verified with old verifier");
240+
SystemDictionaryShared::log_exclusion(klass, "Verified with old verifier");
241241
SystemDictionaryShared::set_excluded(klass);
242242
}
243243
#endif

src/hotspot/share/oops/trainingData.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ void CompileTrainingData::verify(bool verify_dep_counter) {
618618
for (int i = 0; i < init_dep_count(); i++) {
619619
KlassTrainingData* ktd = init_dep(i);
620620
if (ktd->has_holder() && ktd->holder()->defined_by_other_loaders()) {
621-
LogStreamHandle(Warning, training) log;
621+
LogStreamHandle(Info, training) log;
622622
if (log.is_enabled()) {
623623
ResourceMark rm;
624624
log.print("CTD "); print_value_on(&log);

test/hotspot/jtreg/runtime/cds/appcds/aotCache/OldClassSupport.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public String classpath(RunMode runMode) {
6565
@Override
6666
public String[] vmArgs(RunMode runMode) {
6767
return new String[] {
68+
"-Xlog:aot",
6869
"-Xlog:aot+class=debug",
6970
"-Xlog:aot+resolve=trace",
7071
};

test/hotspot/jtreg/runtime/cds/appcds/aotCache/VerifierFailOver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
public class VerifierFailOver {
4040
public static void main(String... args) throws Exception {
4141
SimpleCDSAppTester.of("VerifierFailOver")
42-
.addVmArgs("-Xlog:aot+class=debug")
42+
.addVmArgs("-Xlog:aot,aot+class=debug")
4343
.classpath("app.jar")
4444
.appCommandLine("VerifierFailOverApp")
4545
.setTrainingChecker((OutputAnalyzer out) -> {

test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BulkLoaderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public String classpath(RunMode runMode) {
118118
@Override
119119
public String[] vmArgs(RunMode runMode) {
120120
return new String[] {
121-
"-Xlog:cds,aot+load,cds+class=debug,aot+class=debug",
121+
"-Xlog:cds,aot,aot+load,cds+class=debug,aot+class=debug",
122122
"-XX:+AOTClassLinking",
123123
};
124124
}

0 commit comments

Comments
 (0)