RFR: 8281966: Absolute path of symlink is null in JFileChooser [v6]

Alexey Ivanov aivanov at openjdk.org
Fri Aug 5 12:56:02 UTC 2022


On Fri, 5 Aug 2022 05:46:20 GMT, Tejesh R <tr at openjdk.org> wrote:

>> Absolute path of Symbolic Link created in Windows is set to `null` in `BasicFileChooserUI` class. This happens when propertyChangeListener is implemented to get the Symbolic link's Absolute path on Mouse click through JFileChooser. The reason being that on click of Symbolic link, the _ValueChanged()_ in `BasicFileChooserUI` class has a logic which actually sets the  `chooser.SelectedFile()` to `null` even though the path is not null. Hence the issue is addressed by checking if its a Symbolic link and then setting the `chooser.SelectedFile()` to the value of clicked link without modifying the other logics.
>
> Tejesh R has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Updated based on review comments

Changes requested by aivanov (Reviewer).

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java line 42:

> 40: import java.nio.file.Files;
> 41: import java.nio.file.Path;
> 42: import java.nio.file.Paths;

`Paths` is unused now.
`Path` could be removed too: see below.

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java line 725:

> 723:                                 if ((chooser.isFileSelectionEnabled() && !isDir)
> 724:                                     || (chooser.isDirectorySelectionEnabled()
> 725:                                         && (fsv.isFileSystem(f) || Files.isSymbolicLink(path))

You can inline `f.toPath()` in line 725 and remove the local variable `path` like this:


                                        && (fsv.isFileSystem(f) || Files.isSymbolicLink(f.toPath()))

-------------

PR: https://git.openjdk.org/jdk/pull/9597



More information about the client-libs-dev mailing list