8265604: Support unlinked classes in dynamic CDS archive

Reviewed-by: minqi, iklam
This commit is contained in:
Calvin Cheung 2021-07-20 02:06:42 +00:00
parent 7f35e5bac9
commit 00195b85ed
18 changed files with 117 additions and 80 deletions

View file

@ -262,6 +262,12 @@ bool SystemDictionaryShared::check_for_exclusion_impl(InstanceKlass* k) {
if (k->is_in_error_state()) {
return warn_excluded(k, "In error state");
}
if (k->is_scratch_class()) {
return warn_excluded(k, "A scratch class");
}
if (!k->is_loaded()) {
return warn_excluded(k, "Not in loaded state");
}
if (has_been_redefined(k)) {
return warn_excluded(k, "Has been redefined");
}
@ -283,36 +289,21 @@ bool SystemDictionaryShared::check_for_exclusion_impl(InstanceKlass* k) {
// support them and make CDS more complicated.
return warn_excluded(k, "JFR event class");
}
if (k->init_state() < InstanceKlass::linked) {
// In CDS dumping, we will attempt to link all classes. Those that fail to link will
// be recorded in DumpTimeClassInfo.
Arguments::assert_is_dumping_archive();
// TODO -- rethink how this can be handled.
// We should try to link ik, however, we can't do it here because
// 1. We are at VM exit
// 2. linking a class may cause other classes to be loaded, which means
// a custom ClassLoader.loadClass() may be called, at a point where the
// class loader doesn't expect it.
if (!k->is_linked()) {
if (has_class_failed_verification(k)) {
return warn_excluded(k, "Failed verification");
} else {
if (k->can_be_verified_at_dumptime()) {
return warn_excluded(k, "Not linked");
}
}
}
if (DynamicDumpSharedSpaces && k->major_version() < 50 /*JAVA_6_VERSION*/) {
// In order to support old classes during dynamic dump, class rewriting needs to
// be reverted. This would result in more complex code and testing but not much gain.
ResourceMark rm;
log_warning(cds)("Pre JDK 6 class not supported by CDS: %u.%u %s",
k->major_version(), k->minor_version(), k->name()->as_C_string());
return true;
}
if (!k->can_be_verified_at_dumptime() && k->is_linked()) {
return warn_excluded(k, "Old class has been linked");
} else {
if (!k->can_be_verified_at_dumptime()) {
// We have an old class that has been linked (e.g., it's been executed during
// dump time). This class has been verified using the old verifier, which
// doesn't save the verification constraints, so check_verification_constraints()
// won't work at runtime.
// As a result, we cannot store this class. It must be loaded and fully verified
// at runtime.
return warn_excluded(k, "Old class has been linked");
}
}
if (k->is_hidden() && !is_registered_lambda_proxy_class(k)) {