diff --git a/src/hotspot/share/cds/aotClassLocation.cpp b/src/hotspot/share/cds/aotClassLocation.cpp index 62fc491a0dd..f77aac3540c 100644 --- a/src/hotspot/share/cds/aotClassLocation.cpp +++ b/src/hotspot/share/cds/aotClassLocation.cpp @@ -965,12 +965,7 @@ bool AOTClassLocationConfig::validate(const char* cache_filename, bool has_aot_l log_locations(cache_filename, /*is_write=*/false); - ClassPathEntry* jrt_entry = ClassLoader::get_jrt_entry(); - if (jrt_entry == nullptr) { - log_warning(class, path)("Runtime image (modules) is unreadable or missing - validation failed"); - return false; - } - const char* jrt = jrt_entry->name(); + const char* jrt = ClassLoader::get_jrt_entry()->name(); log_info(class, path)("Checking [0] (modules image)"); bool success = class_location_at(0)->check(jrt, has_aot_linked_classes); log_info(class, path)("Modules image %s validation: %s", jrt, success ? "passed" : "failed"); diff --git a/src/hotspot/share/classfile/classLoader.cpp b/src/hotspot/share/classfile/classLoader.cpp index 12fbda899b9..f6bba6d9d3e 100644 --- a/src/hotspot/share/classfile/classLoader.cpp +++ b/src/hotspot/share/classfile/classLoader.cpp @@ -1418,6 +1418,10 @@ char* ClassLoader::lookup_vm_options() { jio_snprintf(modules_path, JVM_MAXPATHLEN, "%s%slib%smodules", Arguments::get_java_home(), fileSep, fileSep); JImage_file =(*JImageOpen)(modules_path, &error); if (JImage_file == nullptr) { + if (Arguments::has_jimage()) { + // The modules file exists but is unreadable or corrupt + vm_exit_during_initialization(err_msg("Unable to load %s", modules_path)); + } return nullptr; }