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

DirectoryChooser returns the File after following links instead of the symbolic link itself

XMLWordPrintable

    • x86
    • other

      FULL PRODUCT VERSION :
      java version "9-ea"
      Java(TM) SE Runtime Environment (build 9-ea+168)
      Java HotSpot(TM) 64-Bit Server VM (build 9-ea+168, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.15063]

      A DESCRIPTION OF THE PROBLEM :
      Given a symbolic link A which points to a directory B. When I select A by means of a DirectoryChooser, the returned File is B instead of A.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      create a symbolic link to a directory, from the command prompt:
      mklink /D foo bar

      run the JavaFX application below, which simply opens a DirectoryChooser
      select "foo"
      an alert is shown with the result that was returned by the DirectoryChooser, which points to "bar" instead of "foo"

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      the DirectoryChooser must return the symbolic link instead of the directory it points to
      ACTUAL -
      the DirectoryChooser returns the actual directory that the symbolic link points to

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.File;
      import javafx.application.Application;
      import javafx.scene.control.Alert;
      import javafx.stage.DirectoryChooser;
      import javafx.stage.Stage;

      public class JavaFXApplication1 extends Application {

                      @Override
                      public void start(Stage primaryStage) {
                                     primaryStage.show();
                                     DirectoryChooser chooser = new DirectoryChooser();
                                     File f = chooser.showDialog(primaryStage);
                                     if(f != null) {
                                                     new Alert(Alert.AlertType.INFORMATION, f.toString()).showAndWait();
                                     }
                      }

                      public static void main(String[] args) {
                                     launch(args);
                      }

      }

      ---------- END SOURCE ----------

            pmangal Priyanka Mangal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: