RFR: 8355342: File.getCanonicalPath on Java 24 resolves paths on network drives to UNC format [v14]

Brian Burkhalter bpb at openjdk.org
Tue Nov 4 02:02:30 UTC 2025


On Tue, 4 Nov 2025 01:49:44 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> `File.getCanonicalPath` invokes `GetFinalPathNameByHandle` on the result of `canonicalize0` which causes the drive letter of a mapped drive to be converted to a UNC prefix. If such a substitution is detected, this request proposes to revert the conversion of drive letter to UNC prefix before returning the canonical path.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8355342: Do not fail wcanonicalize if getFinalPath fails

Without commit 0918c3a, `JImageExtractTest` was failing as

Invoking testExtractToDirBySymlink
jimage [extract, --dir, .\symlink, C:\tmp\jtreg\scratch.\JImageExtractTest10882108125475978945\smalljdk\lib\modules]
STDERR:
java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
        at java.base/java.lang.reflect.Method.invoke(Method.java:565)
        at JImageCliTest.runTests(JImageCliTest.java:111)
        at JImageExtractTest.main(JImageExtractTest.java:234)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:565)
        at com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:138)
        at java.base/java.lang.Thread.run(Thread.java:1474)
Caused by: java.lang.RuntimeException: Error: cannot create directory C:\tmp\jtreg\scratch.\symlink\java.base\META-INF\services
: expected true, was false
        at jdk.test.lib.Asserts.fail(Asserts.java:715)
        at jdk.test.lib.Asserts.assertTrue(Asserts.java:545)
        at JImageCliTest$JImageResult.assertSuccess(JImageCliTest.java:91)

which was apparently due to `wcanonicalize()` failing when `getFinalPath()` failed for a symlink. Suppressing this failure reinstates the control flow previously defined in the Java layer. With this change, all tier1-tier3 tests pass.

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

PR Comment: https://git.openjdk.org/jdk/pull/27324#issuecomment-3483385436


More information about the core-libs-dev mailing list