< prev index next >

src/hotspot/share/memory/filemap.cpp

Print this page

        

@@ -204,20 +204,24 @@
   _verify_remote = BytecodeVerificationRemote;
   _has_platform_or_app_classes = ClassLoaderExt::has_platform_or_app_classes();
 }
 
 void SharedClassPathEntry::init(const char* name, TRAPS) {
+  assert(DumpSharedSpaces, "dump time only");
   _timestamp = 0;
   _filesize  = 0;
 
   struct stat st;
   if (os::stat(name, &st) == 0) {
     if ((st.st_mode & S_IFMT) == S_IFDIR) {
       _is_dir = true;
     } else {
       _is_dir = false;
+      // 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 {
     // The file/dir must exist, or it would not have been added
     // into ClassLoader::classpath_entry().

@@ -235,10 +239,19 @@
 bool SharedClassPathEntry::validate(bool is_class_path) {
   assert(UseSharedSpaces, "runtime only");
 
   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) {
     // If the archived module path entry does not exist at runtime, it is not fatal
     // (no need to invalid the shared archive) because the shared runtime visibility check

@@ -249,24 +262,22 @@
   } else if (is_dir()) {
     if (!os::dir_is_empty(name)) {
       FileMapInfo::fail_continue("directory is not empty: %s", name);
       ok = false;
     }
-  } else if (is_jar_or_bootimage()) {
-    if (_timestamp != st.st_mtime ||
+  } 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/jimage file is not the one used while building"
+      FileMapInfo::fail_continue("A jar file is not the one used while building"
                                    " the shared archive file: %s", name);
       }
     }
-  }
   return ok;
 }
 
 void SharedClassPathEntry::metaspace_pointers_do(MetaspaceClosure* it) {
   it->push(&_name);
< prev index next >