RFR: 8364277: (fs) BasicFileAttributes.isDirectory and isOther return true for NTFS directory junctions when links not followed [v2]

Johannes Döbler duke at openjdk.org
Tue Aug 5 18:45:05 UTC 2025


On Tue, 5 Aug 2025 17:48:59 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> Change `BasicFileAttributes` for Windows such that for a directory junction `isOther` returns `true` but all other `is*` methods return `false`. Without this change, `isDirectory` also returns `true`.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8364277: 1) Add and use package scope isDirectoryJunction(); 2) Remove explicit delete of junction from test

test/lib/jdk/test/lib/util/FileUtils.java line 449:

> 447: 
> 448:     // Create a link from "junction" to the real path of "target"
> 449:     public static boolean createDirectoryJunction(String junction, String target)

Suggestion: Use Path as type for parameters `junction` and `target` to avoid Path|File->String->Path|File conversions (e.g. the only caller Basic.java already has a Path object for parameter junction, why convert to a String just to recreate a File inside `createDirectoryJunction`).

test/lib/jdk/test/lib/util/FileUtils.java line 463:

> 461:             return createWinDirectoryJunction(junction, target);
> 462:         } else {
> 463:             Files.createSymbolicLink(Path.of(junction), Path.of(target));

Suggestion: Junctions are Windows-only, so why not throw a RuntimeException for the non-windows case (and maybe also rename the method to something like `createWindowsDirectoryJunction`)

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/26631#discussion_r2255068530
PR Review Comment: https://git.openjdk.org/jdk/pull/26631#discussion_r2255040929


More information about the core-libs-dev mailing list