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

Alan Bateman alanb at openjdk.org
Tue Oct 28 07:18:07 UTC 2025


On Mon, 27 Oct 2025 23:24:35 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 with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 11 additional commits since the last revision:
> 
>  - 8355342: Derive final path only for reparse points
>  - Merge
>  - 8355342: Remove unused, vestigial code
>  - 8355342: Do not check for backslash as third character of input pathname string
>  - 8355342: Fall back to canonicalize0() result if drive letter converted to a long / UNC prefix
>  - Merge
>  - Merge
>  - 8355342: Corrected a comment
>  - 8355342: Add missing space in constant declaration
>  - 8355342: Fix possible sneaky NullPointerException
>  - ... and 1 more: https://git.openjdk.org/jdk/compare/642989f9...e4cad2b1

The updated approach in e4cad2b1 to get the final path when a reparse point is encountered looks good. That removes the use of GetFinalPathNameByHandle for the common cases where there is no sym link. It also aligns the behavior with Path::toRealPath. I'll do a detailed pass over the changes (to check for any overflows and other details) as soon as I can.

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

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


More information about the core-libs-dev mailing list