< prev index next >

src/hotspot/share/memory/filemap.cpp

Print this page

@@ -711,10 +711,20 @@
     GrowableArray<const char*>* rp_array = create_path_array(appcp);
     if (rp_array->length() == 0) {
       // None of the jar file specified in the runtime -cp exists.
       return fail("None of the jar file specified in the runtime -cp exists: -Djava.class.path=", appcp);
     }
+
+    // Handling of non-existent entries in the classpath: we eliminate all the non-existent
+    // entries from both the dump time classpath (ClassLoader::update_class_path_entry_list)
+    // and the runtime classpath (FileMapInfo::create_path_array), and check the remaining
+    // entries. E.g.:
+    //
+    // dump : -cp a.jar:NE1:NE2:b.jar  -> a.jar:b.jar -> recorded in archive.
+    // run 1: -cp NE3:a.jar:NE4:b.jar  -> a.jar:b.jar -> matched
+    // run 2: -cp x.jar:NE4:b.jar      -> x.jar:b.jar -> mismatched
+
     int j = _header->_app_class_paths_start_index;
     mismatch = check_paths(j, shared_app_paths_len, rp_array);
     if (mismatch) {
       return fail("[APP classpath mismatch, actual: -Djava.class.path=", appcp);
     }

@@ -805,13 +815,11 @@
       fail_continue("shared class paths mismatch (hint: enable -Xlog:class+path=info to diagnose the failure)");
       return false;
     }
   }
 
-  if (!validate_non_existent_class_paths()) {
-    return false;
-  }
+  validate_non_existent_class_paths();
 
   _validating_shared_path_table = false;
 
 #if INCLUDE_JVMTI
   if (_classpath_entries_for_jvmti != NULL) {

@@ -823,26 +831,30 @@
 #endif
 
   return true;
 }
 
-bool FileMapInfo::validate_non_existent_class_paths() const {
+void FileMapInfo::validate_non_existent_class_paths() {
+  // All of the recorded non-existent paths came from the Class-Path: attribute from the JAR
+  // files on the app classpath. If any of these are found to exist during runtime,
+  // it will change how classes are loading for the app loader. For safety, disable
+  // loading of archived platform/app classes (currently there's no way to disable just the
+  // app classes).
+
   assert(UseSharedSpaces, "runtime only");
   for (int i = _header->_app_module_paths_start_index + _header->_num_module_paths;
        i < get_number_of_shared_paths();
        i++) {
     SharedClassPathEntry* ent = shared_path(i);
     if (!ent->check_non_existent()) {
-      fail_continue("file must not exist: %s", ent->name());
-      return false;
+      warning("Archived non-system classes are disabled because the "
+              "file %s exists", ent->name());
+      _header->_has_platform_or_app_classes = false;
     }
   }
-  return true;
 }
 
-
-
 bool FileMapInfo::check_archive(const char* archive_name, bool is_static) {
   int fd = os::open(archive_name, O_RDONLY | O_BINARY, 0);
   if (fd < 0) {
     // do not vm_exit_during_initialization here because Arguments::init_shared_archive_paths()
     // requires a shared archive name. The open_for_read() function will log a message regarding
< prev index next >