From c71a5567e7a27465dcf77f636a958d39d7edbc79 Mon Sep 17 00:00:00 2001 From: duke Date: Sun, 21 Dec 2025 18:39:04 +0000 Subject: [PATCH] Backport 096b7ff0977ba2455b329b0865a380a1fb4c99d4 --- .../java/nio/file/Files/CopyInterference.java | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/test/jdk/java/nio/file/Files/CopyInterference.java b/test/jdk/java/nio/file/Files/CopyInterference.java index a9319900dc5..310d3e382ca 100644 --- a/test/jdk/java/nio/file/Files/CopyInterference.java +++ b/test/jdk/java/nio/file/Files/CopyInterference.java @@ -24,6 +24,8 @@ /* @test * @bug 8114830 * @summary Verify FileAlreadyExistsException is not thrown for REPLACE_EXISTING + * @library .. + * @build CopyInterference * @run junit CopyInterference */ import java.io.InputStream; @@ -112,17 +114,22 @@ private static Stream pathAndOptionsProvider() new CopyOption[] {REPLACE_EXISTING}); list.add(args); - // symblic link, followed - Path link = dir.resolve("link"); - Files.createSymbolicLink(link, sourceFile); - args = Arguments.of(link, dir.resolve("linkFollowed"), - new CopyOption[] {REPLACE_EXISTING}); - list.add(args); - - // symblic link, not followed - args = Arguments.of(link, dir.resolve("linkNotFollowed"), - new CopyOption[] {REPLACE_EXISTING, NOFOLLOW_LINKS}); - list.add(args); + if (TestUtil.supportsLinks(dir)) { + // symbolic link, followed + Path link = dir.resolve("link"); + Files.createSymbolicLink(link, sourceFile); + args = Arguments.of(link, dir.resolve("linkFollowed"), + new CopyOption[] {REPLACE_EXISTING}); + list.add(args); + + // symbolic link, not followed + args = Arguments.of(link, dir.resolve("linkNotFollowed"), + new CopyOption[] {REPLACE_EXISTING, + NOFOLLOW_LINKS}); + list.add(args); + } else { + System.out.println("Links not supported: not testing links"); + } return list.stream(); }