--- old/src/hotspot/share/memory/filemap.cpp 2019-08-27 10:06:37.533033692 -0700 +++ new/src/hotspot/share/memory/filemap.cpp 2019-08-27 10:06:37.293025022 -0700 @@ -713,6 +713,16 @@ // 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) { @@ -807,9 +817,7 @@ } } - if (!validate_non_existent_class_paths()) { - return false; - } + validate_non_existent_class_paths(); _validating_shared_path_table = false; @@ -825,22 +833,26 @@ 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) {