< prev index next >

src/hotspot/share/classfile/sharedPathsMiscInfo.cpp

Print this page

@@ -22,11 +22,10 @@
  *
  */
 
 #include "precompiled.hpp"
 #include "classfile/classLoader.hpp"
-#include "classfile/classLoaderData.inline.hpp"
 #include "classfile/sharedPathsMiscInfo.hpp"
 #include "logging/log.hpp"
 #include "logging/logStream.hpp"
 #include "memory/allocation.inline.hpp"
 #include "memory/metaspaceShared.hpp"

@@ -34,10 +33,11 @@
 #include "runtime/arguments.hpp"
 #include "runtime/os.inline.hpp"
 #include "utilities/ostream.hpp"
 
 SharedPathsMiscInfo::SharedPathsMiscInfo() {
+  _app_offset = 0;
   _buf_size = INITIAL_BUF_SIZE;
   _cur_ptr = _buf_start = NEW_C_HEAP_ARRAY(char, _buf_size, mtClass);
   _allocated = true;
 }
 

@@ -93,10 +93,16 @@
     out->print("Expecting BOOT path=%s", path);
     break;
   case NON_EXIST:
     out->print("Expecting that %s does not exist", path);
     break;
+  case APP:
+    ClassLoader::trace_class_path("Expecting -Djava.class.path=", path);
+    break;
+  case MODULE:
+    ClassLoader::trace_class_path("Checking module path: ", path);
+    break;
   default:
     ShouldNotReachHere();
   }
 }
 

@@ -153,10 +159,38 @@
         // But we want it to not exist -> fail
         return fail("File must not exist");
       }
     }
     break;
+  case APP:
+    {
+      // Prefix is OK: E.g., dump with -cp foo.jar, but run with -cp foo.jar:bar.jar
+      size_t len = strlen(path);
+      const char *appcp = Arguments::get_appclasspath();
+      assert(appcp != NULL, "NULL app classpath");
+      size_t appcp_len = strlen(appcp);
+      if (appcp_len < len) {
+        return fail("Run time APP classpath is shorter than the one at dump time: ", appcp);
+      }
+      ResourceMark rm;
+      char* tmp_path;
+      if (len == appcp_len) {
+        tmp_path = (char*)appcp;
+      } else {
+        tmp_path = NEW_RESOURCE_ARRAY(char, len + 1);
+        strncpy(tmp_path, appcp, len);
+        tmp_path[len] = 0;
+      }
+      if (os::file_name_strcmp(path, tmp_path) != 0) {
+        return fail("[APP classpath mismatch, actual: -Djava.class.path=", appcp);
+      }
+      if (appcp[len] != '\0' && appcp[len] != os::path_separator()[0]) {
+        return fail("Dump time APP classpath is not a proper prefix of run time APP classpath: ", appcp);
+      }
+    }
+    break;
+    // FIXME: why is there no MODULE check?
   default:
     return fail("Corrupted archive file header");
   }
 
   return true;
< prev index next >