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

(fs) Path.toRealPath throws AccessDeniedException for terminal symlink (win)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • tbd
    • 25
    • core-libs
    • None
    • generic
    • windows

      Given this directory content

      10/01/2025 05:57 PM <DIR> dir
      10/01/2025 05:58 PM <SYMLINKD> dirlink [dir]
      10/01/2025 05:58 PM <JUNCTION> junction [C:\Users\bpb\dev\bugs\dir]
      10/01/2025 05:58 PM <SYMLINK> symlink [dir]

      we get the following results

      jshell> Path.of("dir").toRealPath()
      $7 ==> C:\Users\bpb\dev\bugs\dir

      jshell> Path.of("dirlink").toRealPath()
      $8 ==> C:\Users\bpb\dev\bugs\dir

      jshell> Path.of("junction").toRealPath()
      $9 ==> C:\Users\bpb\dev\bugs\dir

      jshell> Path.of("symlink").toRealPath()
      | Exception java.nio.file.AccessDeniedException: symlink
      | at WindowsException.translateToIOException (WindowsException.java:89)
      | at WindowsException.rethrowAsIOException (WindowsException.java:103)
      | at WindowsException.rethrowAsIOException (WindowsException.java:108)
      | at WindowsLinkSupport.getFinalPath (WindowsLinkSupport.java:102)
      | at WindowsLinkSupport.getRealPath (WindowsLinkSupport.java:263)
      | at WindowsPath.toRealPath (WindowsPath.java:907)
      | at WindowsPath.toRealPath (WindowsPath.java:42)
      | at (#10:1)
      9:55
      jshell> Path.of("symlink", "subdir").toRealPath()
      $11 ==> C:\Users\bpb\dev\bugs\dir\subdir

      where "subdir" is a dub-directory of "dir".

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

              Created:
              Updated:
              Resolved: