RFR: 8281966: Absolute path of symlink is null in JFileChooser [v5]
Alexey Ivanov
aivanov at openjdk.org
Thu Aug 4 18:56:00 UTC 2022
On Thu, 4 Aug 2022 18:45:21 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 720:
> 718: ArrayList<File> fList = new ArrayList<File>(objects.length);
> 719: for (Object object : objects) {
> 720: File f = (File) object;
I'd be grateful if you update this line even though it's not part of your changes:
Suggestion:
File f = (File)object;
It's to make casts consistent. Only this cast has a space before the argument in the entire method.
src/java.desktop/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java line 748:
> 746: if (usesSingleFilePane) {
> 747: Path path = Paths.get(file.getPath());
> 748: if (Files.isSymbolicLink(path)) {
Suggestion:
if (Files.isSymbolicLink(file.toPath())) {
One more instance of `Paths.get` should be replaced with `file.toPath()`.
test/jdk/javax/swing/JFileChooser/FileChooserSymLinkTest.java line 119:
> 117: pathList = new JTextArea(10,50);
> 118: jfc = new JFileChooser(new File("C:\\"));
> 119: passFailJFrame = new PassFailJFrame("Test Instructions",INSTRUCTIONS,5L,35,40);
There should be a space after the comma in parameter list.
test/jdk/javax/swing/JFileChooser/FileChooserSymLinkTest.java line 125:
> 123: frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
> 124: panel.add(multiSelection,BorderLayout.EAST);
> 125: panel.add(new JScrollPane(pathList),BorderLayout.WEST);
Space after comma.
-------------
PR: https://git.openjdk.org/jdk/pull/9597
More information about the client-libs-dev
mailing list