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

[macosx] FileDialog.getDirectory() returns incorrect directory

    Details

    • Subcomponent:
    • Resolved In Build:
      b16
    • CPU:
      generic
    • OS:
      os_x
    • Verification:
      Verified

      Backports

        Description

        Here's the test to reproduce the issue with the latest build:

        import java.awt.*;
        import java.io.File;

        public class OpenFile {
            public static final void main(String args[]) throws Exception{

                FileDialog openDialog = new FileDialog((Frame)null);
                openDialog.setVisible(true);

                if (openDialog.getFile() == null) {
                    throw new RuntimeException("dialog cancelled");
                }

                String filename = openDialog.getFile();
                String folder = openDialog.getDirectory();
                File file = new File(folder + File.separator + filename);
                boolean exists = file.exists();
        System.err.println(" exists="+exists);
            }
        }

        The app simply asks user to choose any file and then create an instance of the io.File class and just prints whether the file exists or not. The test passes (that is file.exists returns true) on Apple's JDK and on Oracle's JDK before the changes for multipe-files support in FileDialog:

        http://hg.openjdk.java.net/jdk7u/jdk7u-dev/jdk/rev/0e2f3e494814

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  dcherepanov Dmitry Cherepanov
                  Reporter:
                  dcherepanov Dmitry Cherepanov
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: