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

(fs) Path.toRealPath(LinkOption.NOFOLLOW_LINKS) fails when "../../" follows a link (win)

    XMLWordPrintable

Details

    • b16
    • windows

    Description

      A similar issue as reported for Unix in JDK-8306882.

      If one has these files

      ./dir/subdir
      ./aaa@ -> dir/subdir
      ./out.txt

      then trying to get the real path of "aaa/../../out.txt" in jshell gives:

      jshell> Path p = Path.of("aaa/../../out.txt")
      p ==> aaa\..\..\out.txt

      jshell> p.toRealPath()
      | Exception java.nio.file.NoSuchFileException: C:\Users\out.txt
      | at WindowsException.translateToIOException (WindowsException.java:85)
      | at WindowsException.rethrowAsIOException (WindowsException.java:96)
      | at WindowsLinkSupport.getRealPath (WindowsLinkSupport.java:288)
      | at WindowsPath.toRealPath (WindowsPath.java:944)
      | at WindowsPath.toRealPath (WindowsPath.java:42)
      | at (#2:1)

      jshell> p.toRealPath(LinkOption.NOFOLLOW_LINKS)
      | Exception java.nio.file.NoSuchFileException: C:\Users\out.txt
      | at WindowsException.translateToIOException (WindowsException.java:85)
      | at WindowsException.rethrowAsIOException (WindowsException.java:96)
      | at WindowsLinkSupport.getRealPath (WindowsLinkSupport.java:288)
      | at WindowsPath.toRealPath (WindowsPath.java:944)
      | at WindowsPath.toRealPath (WindowsPath.java:42)
      | at (#3:1)

      Therefore toRealPath() fails whether or not links are followed.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: