mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8259070: Add jcmd option to dump CDS
Reviewed-by: ccheung, iklam, mli
This commit is contained in:
parent
593194864a
commit
e7cbeba866
23 changed files with 800 additions and 75 deletions
|
@ -3672,7 +3672,7 @@ const char* InstanceKlass::internal_name() const {
|
|||
void InstanceKlass::print_class_load_logging(ClassLoaderData* loader_data,
|
||||
const ModuleEntry* module_entry,
|
||||
const ClassFileStream* cfs) const {
|
||||
log_to_classlist(cfs);
|
||||
log_to_classlist();
|
||||
|
||||
if (!log_is_enabled(Info, class, load)) {
|
||||
return;
|
||||
|
@ -4265,53 +4265,37 @@ unsigned char * InstanceKlass::get_cached_class_file_bytes() {
|
|||
}
|
||||
#endif
|
||||
|
||||
void InstanceKlass::log_to_classlist(const ClassFileStream* stream) const {
|
||||
bool InstanceKlass::is_shareable() const {
|
||||
#if INCLUDE_CDS
|
||||
ClassLoaderData* loader_data = class_loader_data();
|
||||
if (!SystemDictionaryShared::is_sharing_possible(loader_data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_hidden() || unsafe_anonymous_host() != NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (module()->is_patched()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void InstanceKlass::log_to_classlist() const {
|
||||
#if INCLUDE_CDS
|
||||
ResourceMark rm;
|
||||
if (ClassListWriter::is_enabled()) {
|
||||
if (!ClassLoader::has_jrt_entry()) {
|
||||
warning("DumpLoadedClassList and CDS are not supported in exploded build");
|
||||
DumpLoadedClassList = NULL;
|
||||
return;
|
||||
}
|
||||
ClassLoaderData* loader_data = class_loader_data();
|
||||
if (!SystemDictionaryShared::is_sharing_possible(loader_data)) {
|
||||
return;
|
||||
}
|
||||
bool skip = false;
|
||||
if (is_shared()) {
|
||||
assert(stream == NULL, "shared class with stream");
|
||||
if (is_hidden()) {
|
||||
// Don't include archived lambda proxy class in the classlist.
|
||||
assert(!is_non_strong_hidden(), "unexpected non-strong hidden class");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
assert(stream != NULL, "non-shared class without stream");
|
||||
// skip hidden class and unsafe anonymous class.
|
||||
if ( is_hidden() || unsafe_anonymous_host() != NULL) {
|
||||
return;
|
||||
}
|
||||
oop class_loader = loader_data->class_loader();
|
||||
if (class_loader == NULL || SystemDictionary::is_platform_class_loader(class_loader)) {
|
||||
// For the boot and platform class loaders, skip classes that are not found in the
|
||||
// java runtime image, such as those found in the --patch-module entries.
|
||||
// These classes can't be loaded from the archive during runtime.
|
||||
if (!stream->from_boot_loader_modules_image() && strncmp(stream->source(), "jrt:", 4) != 0) {
|
||||
skip = true;
|
||||
}
|
||||
|
||||
if (class_loader == NULL && ClassLoader::contains_append_entry(stream->source())) {
|
||||
// .. but don't skip the boot classes that are loaded from -Xbootclasspath/a
|
||||
// as they can be loaded from the archive during runtime.
|
||||
skip = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
ResourceMark rm;
|
||||
if (skip) {
|
||||
tty->print_cr("skip writing class %s from source %s to classlist file",
|
||||
name()->as_C_string(), stream->source());
|
||||
} else {
|
||||
if (is_shareable()) {
|
||||
ClassListWriter w;
|
||||
w.stream()->print_cr("%s", name()->as_C_string());
|
||||
w.stream()->flush();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue