--- old/src/hotspot/share/memory/filemap.cpp 2018-05-13 20:25:26.951790489 -0400 +++ new/src/hotspot/share/memory/filemap.cpp 2018-05-13 20:25:25.655715552 -0400 @@ -206,6 +206,7 @@ } void SharedClassPathEntry::init(const char* name, TRAPS) { + assert(DumpSharedSpaces, "dump time only"); _timestamp = 0; _filesize = 0; @@ -215,7 +216,10 @@ _is_dir = true; } else { _is_dir = false; - _timestamp = st.st_mtime; + // The timestamp of the modules_image is not checked at runtime. + if (!ClassLoader::is_modules_image(name)) { + _timestamp = st.st_mtime; + } _filesize = st.st_size; } } else { @@ -237,6 +241,15 @@ struct stat st; const char* name = this->name(); + + // We need to validate the runtime modules image file size against the archived + // size information, obtain the runtime modules image path. The recorded dump + // time modules image path in the archive may be different from the runtime path + // if the JDK image has beed moved after generating the archive. + if (ClassLoader::is_modules_image(name)) { + name = ClassLoader::get_jrt_entry()->name(); + } + bool ok = true; log_info(class, path)("checking shared classpath entry: %s", name); if (os::stat(name, &st) != 0 && is_class_path) { @@ -251,18 +264,16 @@ FileMapInfo::fail_continue("directory is not empty: %s", name); ok = false; } - } else if (is_jar_or_bootimage()) { - if (_timestamp != st.st_mtime || - _filesize != st.st_size) { - ok = false; - if (PrintSharedArchiveAndExit) { - FileMapInfo::fail_continue(_timestamp != st.st_mtime ? - "Timestamp mismatch" : - "File size mismatch"); - } else { - FileMapInfo::fail_continue("A jar/jimage file is not the one used while building" - " the shared archive file: %s", name); - } + } else if ((has_timestamp() && _timestamp != st.st_mtime) || + _filesize != st.st_size) { + ok = false; + if (PrintSharedArchiveAndExit) { + FileMapInfo::fail_continue(_timestamp != st.st_mtime ? + "Timestamp mismatch" : + "File size mismatch"); + } else { + FileMapInfo::fail_continue("A jar file is not the one used while building" + " the shared archive file: %s", name); } } return ok;