diff --git a/src/hotspot/share/cds/aotClassLocation.cpp b/src/hotspot/share/cds/aotClassLocation.cpp index f77aac3540c..62fc491a0dd 100644 --- a/src/hotspot/share/cds/aotClassLocation.cpp +++ b/src/hotspot/share/cds/aotClassLocation.cpp @@ -965,7 +965,12 @@ bool AOTClassLocationConfig::validate(const char* cache_filename, bool has_aot_l log_locations(cache_filename, /*is_write=*/false); - const char* jrt = ClassLoader::get_jrt_entry()->name(); + 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(); 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");