--- old/src/hotspot/os/windows/os_windows.cpp 2018-05-04 21:17:07.397127479 -0700 +++ new/src/hotspot/os/windows/os_windows.cpp 2018-05-04 21:17:07.123101610 -0700 @@ -4384,10 +4384,11 @@ return false; } strcpy(search_path, path); + os::native_path(search_path); // Append "*", or possibly "\\*", to path - if (path[1] == ':' && - (path[2] == '\0' || - (path[2] == '\\' && path[3] == '\0'))) { + if (search_path[1] == ':' && + (search_path[2] == '\0' || + (search_path[2] == '\\' && search_path[3] == '\0'))) { // No '\\' needed for cases like "Z:" or "Z:\" strcat(search_path, "*"); } --- old/src/hotspot/share/classfile/classLoader.cpp 2018-05-04 21:17:08.098193663 -0700 +++ new/src/hotspot/share/classfile/classLoader.cpp 2018-05-04 21:17:07.830168360 -0700 @@ -1557,17 +1557,19 @@ PackageEntry* pkg_entry = ik->package(); if (FileMapInfo::get_number_of_shared_paths() > 0) { - char* canonical_path = NEW_RESOURCE_ARRAY(char, JVM_MAXPATHLEN); + char* canonical_path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, JVM_MAXPATHLEN); // save the path from the file: protocol or the module name from the jrt: protocol // if no protocol prefix is found, path is the same as stream->source() char* path = skip_uri_protocol(src); + char* canonical_src_path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, JVM_MAXPATHLEN); for (int i = 0; i < FileMapInfo::get_number_of_shared_paths(); i++) { SharedClassPathEntry* ent = FileMapInfo::shared_path(i); - if (get_canonical_path(ent->name(), canonical_path, JVM_MAXPATHLEN)) { + if (get_canonical_path(ent->name(), canonical_path, JVM_MAXPATHLEN) && + get_canonical_path(path, canonical_src_path, JVM_MAXPATHLEN)) { // If the path (from the class stream source) is the same as the shared // class or module path, then we have a match. - if (strcmp(canonical_path, os::native_path((char*)path)) == 0) { + if (strcmp(canonical_path, canonical_src_path) == 0) { // NULL pkg_entry and pkg_entry in an unnamed module implies the class // is from the -cp or boot loader append path which consists of -Xbootclasspath/a // and jvmti appended entries. --- old/src/hotspot/share/classfile/classLoaderExt.cpp 2018-05-04 21:17:08.759256070 -0700 +++ new/src/hotspot/share/classfile/classLoaderExt.cpp 2018-05-04 21:17:08.494231051 -0700 @@ -81,12 +81,11 @@ } void ClassLoaderExt::process_module_table(ModuleEntryTable* met, TRAPS) { - ResourceMark rm; + ResourceMark rm(THREAD); for (int i = 0; i < met->table_size(); i++) { for (ModuleEntry* m = met->bucket(i); m != NULL;) { char* path = m->location()->as_C_string(); - if (strncmp(path, "file:", 5) == 0 && ClassLoader::string_ends_with(path, ".jar")) { - m->print(); + if (strncmp(path, "file:", 5) == 0) { path = ClassLoader::skip_uri_protocol(path); ClassLoader::setup_module_search_path(path, THREAD); } --- old/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/MainModuleOnly.java 2018-05-04 21:17:09.420318477 -0700 +++ new/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/MainModuleOnly.java 2018-05-04 21:17:09.147292703 -0700 @@ -173,5 +173,14 @@ "-m", TEST_MODULE1) .assertAbnormalExit( "A jar/jimage file is not the one used while building the shared archive file:"); + // create an archive with a non-empty directory in the --module-path. + // The dumping process will exit with an error due to non-empty directory + // in the --module-path. + output = TestCommon.createArchive(destJar.toString(), appClasses, + "-Xlog:class+load=trace", + "--module-path", MODS_DIR.toString(), + "-m", TEST_MODULE1); + output.shouldHaveExitValue(1) + .shouldMatch("Error: non-empty directory.*com.simple"); } }