7067885: FileChooser does not display soft link name if link is to nonexistent file/directory
authoralexsch
Wed, 05 Oct 2016 18:52:06 +0400
changeset 41775 cd8702847ab1
parent 41774 e9156811f79c
child 41776 71e2575dd727
7067885: FileChooser does not display soft link name if link is to nonexistent file/directory Reviewed-by: alexsch Contributed-by: Alok Kumar Sharma <alok.sharma@hpe.com>
jdk/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java
--- a/jdk/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java	Wed Oct 05 18:42:34 2016 +0400
+++ b/jdk/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java	Wed Oct 05 18:52:06 2016 +0400
@@ -30,6 +30,10 @@
 import java.awt.Toolkit;
 import java.io.*;
 import java.io.FileNotFoundException;
+import java.nio.file.Files;
+import java.nio.file.LinkOption;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.*;
 import java.util.concurrent.Callable;
 
@@ -240,10 +244,11 @@
      * @exception FileNotFoundException if file does not exist
      */
     public static ShellFolder getShellFolder(File file) throws FileNotFoundException {
+        Path path = Paths.get(file.getPath());
         if (file instanceof ShellFolder) {
             return (ShellFolder)file;
         }
-        if (!file.exists()) {
+        if (!Files.exists(path, LinkOption.NOFOLLOW_LINKS)) {
             throw new FileNotFoundException();
         }
         return shellFolderManager.createShellFolder(file);