RFR: 8355342: File.getCanonicalPath on Java 24 resolves paths on network drives to UNC format [v6]
Brian Burkhalter
bpb at openjdk.org
Mon Oct 20 20:59:04 UTC 2025
On Sun, 19 Oct 2025 08:30:16 GMT, Alan Bateman <alanb at openjdk.org> wrote:
> Would it be possible to paste in the outcome from the latest change with files that exist, and do not exist, on the UNC share. I think it would be useful to have both the toRealPath and File.getCanonicalPath outcome.
In the following, the `getCanonicalPath` output is with commit 68af87c7, and the `toRealPath` output is with no changes versus mainline.
### Z: mapped to `\\localhost\c$\Temp`
| Pathname string | File.getCanonicalPath | Path.toRealPath |
| :---: | :---: | :---: |
| Z:\file.txt | "Z:\\file.txt" | Z:\file.txt |
| Z:\linktofile | "Z:\\linktofile" | \\localhost\c$\Temp\file.txt |
| Z:\linktonotexist | "Z:\\linktonotexist" | NoSuchFileException |
### Z: mapped to `\\192.168.0.104\somewhere`
| Pathname string | File.getCanonicalPath | Path.toRealPath |
| :---: | :---: | :---: |
| Z:\file.txt | "Z:\\file.txt" | Z:\file.txt |
| Z:\linktofile | "Z:\\linktofile" | FileSystemException (*) |
| Z:\linktonotexist | "Z:\\linktonotexist" | FileSystemException (*) |
(*) The name of the file cannot be resolved by the system
(Windows error code ERROR_CANT_RESOLVE_FILENAME (1921).)
-------------
PR Comment: https://git.openjdk.org/jdk/pull/27324#issuecomment-3423689791
More information about the core-libs-dev
mailing list