diff --git a/make/RunTests.gmk b/make/RunTests.gmk index 98df3be6e65..f2f1877fff1 100644 --- a/make/RunTests.gmk +++ b/make/RunTests.gmk @@ -849,10 +849,14 @@ define SetupRunJtregTestBody $1_JTREG_LAUNCHER_OPTIONS += -Xmx$$($1_JTREG_MAX_MEM) endif + # Make sure the tmp dir is normalized as some tests will react badly otherwise + $1_TEST_TMP_DIR := $$(abspath $$($1_TEST_SUPPORT_DIR)/tmp) + $1_JTREG_BASIC_OPTIONS += -$$($1_JTREG_TEST_MODE) \ -verbose:$$(JTREG_VERBOSE) -retain:$$(JTREG_RETAIN) \ -concurrency:$$($1_JTREG_JOBS) -timeoutFactor:$$(JTREG_TIMEOUT_FACTOR) \ - -vmoption:-XX:MaxRAMPercentage=$$($1_JTREG_MAX_RAM_PERCENTAGE) + -vmoption:-XX:MaxRAMPercentage=$$($1_JTREG_MAX_RAM_PERCENTAGE) \ + -vmoption:-Djava.io.tmpdir="$$($1_TEST_TMP_DIR)" $1_JTREG_BASIC_OPTIONS += -automatic -ignore:quiet @@ -968,7 +972,8 @@ define SetupRunJtregTestBody run-test-$1: pre-run-test clean-workdir-$1 $$($1_AOT_TARGETS) $$(call LogWarn) $$(call LogWarn, Running test '$$($1_TEST)') - $$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR)) + $$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR) \ + $$($1_TEST_TMP_DIR)) $$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/jtreg, ( \ $$(COV_ENVIRONMENT) $$($1_COMMAND_LINE) \ )) diff --git a/test/jdk/java/nio/file/Path/Misc.java b/test/jdk/java/nio/file/Path/Misc.java index 424a60d6bdc..ad1640c23b8 100644 --- a/test/jdk/java/nio/file/Path/Misc.java +++ b/test/jdk/java/nio/file/Path/Misc.java @@ -120,8 +120,22 @@ public class Misc { * Test: toRealPath() should resolve links */ if (supportsLinks) { - Files.createSymbolicLink(link, file.toAbsolutePath()); - assertTrue(link.toRealPath().equals(file.toRealPath())); + Path resolvedFile = file; + if (isWindows) { + // Path::toRealPath does not work with environments using the + // legacy subst mechanism. This is a workaround to keep the + // test working if 'dir' points to a location on a subst drive. + // See JDK-8213216. + // + Path tempLink = dir.resolve("tempLink"); + Files.createSymbolicLink(tempLink, dir.toAbsolutePath()); + Path resolvedDir = tempLink.toRealPath(); + Files.delete(tempLink); + resolvedFile = resolvedDir.resolve(file.getFileName()); + } + + Files.createSymbolicLink(link, resolvedFile.toAbsolutePath()); + assertTrue(link.toRealPath().equals(resolvedFile.toRealPath())); Files.delete(link); }