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

File.getCanonicalFile() does not resolve symlinks on MS Windows

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 24
    • 7u9
    • core-libs
    • Windows 7, JDK 1.7

    • b15
    • generic
    • windows

      Steps to reproduce:

      Create a symlink on MS Windows (NTFS file system):
      F:\> mkdir link-target
      F:\> mklink /D link f:\link-target
      symbolic link created for link <<===>> f:\link-target

      Run this Java code:
      public static void main(String[] args) throws IOException {
          File file = new File("f:\\link");
          System.out.println(file);
          System.out.println(file.getCanonicalFile());
          System.out.println(file.getCanonicalFile().getCanonicalFile());
      }

      The result is:

      f:\link
      F:\link
      F:\link

      See also this NetBeans issue: http://netbeans.org/bugzilla/show_bug.cgi?id=222158

            bpb Brian Burkhalter
            saubrech Stanislav Aubrecht
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: