RFR: 8003887: File.getCanonicalFile() does not resolve symlinks on MS Windows [v4]

Alan Bateman alanb at openjdk.org
Wed Sep 4 08:47:21 UTC 2024


On Tue, 3 Sep 2024 21:50:32 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> Return the final path derived from the string returned by `canonicalize0()`.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8003887: Test getCanonicalPath when the path contains links

src/java.base/windows/native/libjava/WinNTFileSystem_md.c line 347:

> 345: 
> 346:     if (rv == NULL && !(*env)->ExceptionCheck(env)) {
> 347:         JNU_ThrowIOExceptionWithLastError(env, "Bad pathname"); // XXX message?

That "not useful" exception message is probably okay because this is what canonicalize has always used.

test/jdk/java/io/File/GetCanonicalPath.java line 129:

> 127:     }
> 128: 
> 129:     private static Path createPath(String pathname) throws IOException {

This method creates a File, returning a Path to the file, so maybe better method name needed here.

test/jdk/java/io/File/GetCanonicalPath.java line 135:

> 133:     }
> 134: 
> 135:     private static boolean testLinks = true;

It might be clearer to replace this with supportsLinks and have the tests Assumptions.asserTrue(supportsLinks) so they will be skipped when not supported.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20801#discussion_r1743316741
PR Review Comment: https://git.openjdk.org/jdk/pull/20801#discussion_r1743319200
PR Review Comment: https://git.openjdk.org/jdk/pull/20801#discussion_r1743322928


More information about the core-libs-dev mailing list