Move runtime image check to early VM init

Suggested-by: Ioi Lam
This commit is contained in:
Boris Ulasevich 2026-01-23 14:15:19 -03:00
parent f3da8c8267
commit 8152b3b2d0
2 changed files with 5 additions and 6 deletions

View File

@ -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");

View File

@ -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;
}