With drive Z: mapped to the directory C:\Temp with contents
Directory of C:\Temp
09/17/2025 08:37 AM <DIR> .
09/17/2025 08:36 AM <SYMLINK> link [target.txt]
09/10/2025 04:41 PM 18 target.txt
then
Path.of("Z:\\file.txt").toRealPath() -> Z:\file.txt
but
Path.of("Z:\\link").toRealPath() -> \\localhost\c$\Temp\file.txt
and the mapped drive is expanded to a UNC path. However, with Z: mapped via Samba to a remote folder with the same contents, then for the regular file the result is the same
Path.of("Z:\\file.txt").toRealPath() -> Z:\file.txt
but for the link
Path.of("Z:\\link").toRealPath()
throws an exception:
| Exception java.nio.file.FileSystemException: Z:\link: The name of the file cannot be resolved by the system
| at WindowsException.translateToIOException (WindowsException.java:92)
| at WindowsException.rethrowAsIOException (WindowsException.java:103)
| at WindowsException.rethrowAsIOException (WindowsException.java:108)
| at WindowsLinkSupport.getFinalPath (WindowsLinkSupport.java:104)
| at WindowsLinkSupport.getRealPath (WindowsLinkSupport.java:271)
| at WindowsPath.toRealPath (WindowsPath.java:944)
| at WindowsPath.toRealPath (WindowsPath.java:42)
Directory of C:\Temp
09/17/2025 08:37 AM <DIR> .
09/17/2025 08:36 AM <SYMLINK> link [target.txt]
09/10/2025 04:41 PM 18 target.txt
then
Path.of("Z:\\file.txt").toRealPath() -> Z:\file.txt
but
Path.of("Z:\\link").toRealPath() -> \\localhost\c$\Temp\file.txt
and the mapped drive is expanded to a UNC path. However, with Z: mapped via Samba to a remote folder with the same contents, then for the regular file the result is the same
Path.of("Z:\\file.txt").toRealPath() -> Z:\file.txt
but for the link
Path.of("Z:\\link").toRealPath()
throws an exception:
| Exception java.nio.file.FileSystemException: Z:\link: The name of the file cannot be resolved by the system
| at WindowsException.translateToIOException (WindowsException.java:92)
| at WindowsException.rethrowAsIOException (WindowsException.java:103)
| at WindowsException.rethrowAsIOException (WindowsException.java:108)
| at WindowsLinkSupport.getFinalPath (WindowsLinkSupport.java:104)
| at WindowsLinkSupport.getRealPath (WindowsLinkSupport.java:271)
| at WindowsPath.toRealPath (WindowsPath.java:944)
| at WindowsPath.toRealPath (WindowsPath.java:42)
- relates to
-
JDK-8355342 File.getCanonicalPath on Java 24 resolves paths on network drives to UNC format
-
- In Progress
-