mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8209598: Clean up how messages are printed when CDS aborts start-up
Added a new function vm_exit_during_cds_dumping() to java.cpp so that it can be used when an error condition is encountered during CDS dumping. Reviewed-by: iklam, dholmes, jiangli
This commit is contained in:
parent
8dbea74827
commit
7c81535d46
6 changed files with 37 additions and 18 deletions
|
@ -1471,16 +1471,16 @@ void ClassLoader::record_result(InstanceKlass* ik, const ClassFileStream* stream
|
||||||
// if no protocol prefix is found, path is the same as stream->source()
|
// if no protocol prefix is found, path is the same as stream->source()
|
||||||
char* path = skip_uri_protocol(src);
|
char* path = skip_uri_protocol(src);
|
||||||
char* canonical_class_src_path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, JVM_MAXPATHLEN);
|
char* canonical_class_src_path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, JVM_MAXPATHLEN);
|
||||||
if (!get_canonical_path(path, canonical_class_src_path, JVM_MAXPATHLEN)) {
|
bool success = get_canonical_path(path, canonical_class_src_path, JVM_MAXPATHLEN);
|
||||||
tty->print_cr("Bad pathname %s. CDS dump aborted.", path);
|
// The path is from the ClassFileStream. Since a ClassFileStream has been created successfully in functions
|
||||||
vm_exit(1);
|
// such as ClassLoader::load_class(), its source path must be valid.
|
||||||
}
|
assert(success, "must be valid path");
|
||||||
for (int i = 0; i < FileMapInfo::get_number_of_shared_paths(); i++) {
|
for (int i = 0; i < FileMapInfo::get_number_of_shared_paths(); i++) {
|
||||||
SharedClassPathEntry* ent = FileMapInfo::shared_path(i);
|
SharedClassPathEntry* ent = FileMapInfo::shared_path(i);
|
||||||
if (!get_canonical_path(ent->name(), canonical_path_table_entry, JVM_MAXPATHLEN)) {
|
success = get_canonical_path(ent->name(), canonical_path_table_entry, JVM_MAXPATHLEN);
|
||||||
tty->print_cr("Bad pathname %s. CDS dump aborted.", ent->name());
|
// A shared path has been validated during its creation in ClassLoader::create_class_path_entry(),
|
||||||
vm_exit(1);
|
// it must be valid here.
|
||||||
}
|
assert(success, "must be valid path");
|
||||||
// If the path (from the class stream source) is the same as the shared
|
// If the path (from the class stream source) is the same as the shared
|
||||||
// class or module path, then we have a match.
|
// class or module path, then we have a match.
|
||||||
if (strcmp(canonical_path_table_entry, canonical_class_src_path) == 0) {
|
if (strcmp(canonical_path_table_entry, canonical_class_src_path) == 0) {
|
||||||
|
|
|
@ -175,8 +175,7 @@ void ClassLoaderExt::process_jar_manifest(ClassPathEntry* entry,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strstr(manifest, "Extension-List:") != NULL) {
|
if (strstr(manifest, "Extension-List:") != NULL) {
|
||||||
tty->print_cr("-Xshare:dump does not support Extension-List in JAR manifest: %s", entry->name());
|
vm_exit_during_cds_dumping(err_msg("-Xshare:dump does not support Extension-List in JAR manifest: %s", entry->name()));
|
||||||
vm_exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char* cp_attr = get_class_path_attr(entry->name(), manifest, manifest_size);
|
char* cp_attr = get_class_path_attr(entry->name(), manifest, manifest_size);
|
||||||
|
|
|
@ -1291,10 +1291,9 @@ MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size,
|
||||||
if (DumpSharedSpaces) {
|
if (DumpSharedSpaces) {
|
||||||
// CDS dumping keeps loading classes, so if we hit an OOM we probably will keep hitting OOM.
|
// CDS dumping keeps loading classes, so if we hit an OOM we probably will keep hitting OOM.
|
||||||
// We should abort to avoid generating a potentially bad archive.
|
// We should abort to avoid generating a potentially bad archive.
|
||||||
tty->print_cr("Failed allocating metaspace object type %s of size " SIZE_FORMAT ". CDS dump aborted.",
|
vm_exit_during_cds_dumping(err_msg("Failed allocating metaspace object type %s of size " SIZE_FORMAT ". CDS dump aborted.",
|
||||||
MetaspaceObj::type_name(type), word_size * BytesPerWord);
|
MetaspaceObj::type_name(type), word_size * BytesPerWord),
|
||||||
tty->print_cr("Please increase MaxMetaspaceSize (currently " SIZE_FORMAT " bytes).", MaxMetaspaceSize);
|
err_msg("Please increase MaxMetaspaceSize (currently " SIZE_FORMAT " bytes).", MaxMetaspaceSize));
|
||||||
vm_exit(1);
|
|
||||||
}
|
}
|
||||||
report_metadata_oome(loader_data, word_size, type, mdtype, THREAD);
|
report_metadata_oome(loader_data, word_size, type, mdtype, THREAD);
|
||||||
assert(HAS_PENDING_EXCEPTION, "sanity");
|
assert(HAS_PENDING_EXCEPTION, "sanity");
|
||||||
|
|
|
@ -1646,12 +1646,11 @@ void MetaspaceShared::link_and_cleanup_shared_classes(TRAPS) {
|
||||||
} while (check_closure.made_progress());
|
} while (check_closure.made_progress());
|
||||||
|
|
||||||
if (IgnoreUnverifiableClassesDuringDump) {
|
if (IgnoreUnverifiableClassesDuringDump) {
|
||||||
// This is useful when running JCK or SQE tests. You should not
|
// IgnoreUnverifiableClassesDuringDump is enabled by default.
|
||||||
// enable this when running real apps.
|
// Unverifiable classes will not be included in the CDS archive.
|
||||||
SystemDictionary::remove_classes_in_error_state();
|
SystemDictionary::remove_classes_in_error_state();
|
||||||
} else {
|
} else {
|
||||||
tty->print_cr("Please remove the unverifiable classes from your class list and try again");
|
vm_exit_during_cds_dumping("Please remove the unverifiable classes from your class list and try again");
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -609,6 +609,26 @@ void vm_abort(bool dump_core) {
|
||||||
ShouldNotReachHere();
|
ShouldNotReachHere();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vm_notify_during_cds_dumping(const char* error, const char* message) {
|
||||||
|
if (error != NULL) {
|
||||||
|
tty->print_cr("Error occurred during CDS dumping");
|
||||||
|
tty->print("%s", error);
|
||||||
|
if (message != NULL) {
|
||||||
|
tty->print_cr(": %s", message);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tty->cr();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void vm_exit_during_cds_dumping(const char* error, const char* message) {
|
||||||
|
vm_notify_during_cds_dumping(error, message);
|
||||||
|
|
||||||
|
// Failure during CDS dumping, we don't want to dump core
|
||||||
|
vm_abort(false);
|
||||||
|
}
|
||||||
|
|
||||||
void vm_notify_during_shutdown(const char* error, const char* message) {
|
void vm_notify_during_shutdown(const char* error, const char* message) {
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
tty->print_cr("Error occurred during initialization of VM");
|
tty->print_cr("Error occurred during initialization of VM");
|
||||||
|
|
|
@ -51,6 +51,8 @@ extern void vm_exit_during_initialization(Symbol* exception_name, const char* me
|
||||||
extern void vm_exit_during_initialization(const char* error, const char* message = NULL);
|
extern void vm_exit_during_initialization(const char* error, const char* message = NULL);
|
||||||
extern void vm_shutdown_during_initialization(const char* error, const char* message = NULL);
|
extern void vm_shutdown_during_initialization(const char* error, const char* message = NULL);
|
||||||
|
|
||||||
|
extern void vm_exit_during_cds_dumping(const char* error, const char* message = NULL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* With the integration of the changes to handle the version string
|
* With the integration of the changes to handle the version string
|
||||||
* as defined by JEP-223, most of the code related to handle the version
|
* as defined by JEP-223, most of the code related to handle the version
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue