Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8368165

(fs) Path.toRealPath does not perform correctly for symbolic links in a mapped drive (win)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 26
    • core-libs
    • None
    • generic
    • windows

      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)

            bpb Brian Burkhalter
            bpb Brian Burkhalter
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: