JDK-8368165 : (fs) Path.toRealPath does not perform correctly for symbolic links in a mapped drive (win)
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 26
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows
  • CPU: generic
  • Submitted: 2025-09-19
  • Updated: 2025-09-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
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)
Comments
There are many Windows <-> SAMBA interop issues, you may have to repeat this with 2 Windows machines to see how GetFinalPathNameByHandle behaves.
20-09-2025