RFR: 8281966: Absolute path of symlink is null in JFileChooser
Alexey Ivanov
aivanov at openjdk.org
Fri Jul 29 18:31:15 UTC 2022
On Thu, 21 Jul 2022 18:31:46 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.
I wonder if it's possible to create the symbolic link for the tester. Does [Files.html.createSymbolicLink](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/file/Files.html#createSymbolicLink(java.nio.file.Path,java.nio.file.Path,java.nio.file.attribute.FileAttribute...)) not work?
It would be much more convenient for the tester and you would open the `JFileChooser` in the directory where you created the target and the link.
It may even be possible to automate the test altogether. If you explicitly set the L&F to Metal, you can use mnemonics and keyboard to select the link inside the directory and verify if `valueChanged` resets the file to `null`.
src/java.desktop/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java line 749:
> 747: } else {
> 748: chooser.setSelectedFile(null);
> 749: }
What about the case where multiselection is enabled? It likely needs updating too.
test/jdk/javax/swing/JFileChooser/FileChooserSymLinkTest.java line 32:
> 30: is valid on ValueChanged property listener.
> 31: @run main FileChooserSymLinkTest
> 32: */
May I ask to place these tags before the class declaration?
Add the asterisk to each line, like you see in the copyright and other tests.
test/jdk/javax/swing/JFileChooser/FileChooserSymLinkTest.java line 45:
> 43: import javax.swing.WindowConstants;
> 44:
> 45: public class FileChooserSymLinkTest{
Suggestion:
public class FileChooserSymLinkTest {
test/jdk/javax/swing/JFileChooser/FileChooserSymLinkTest.java line 76:
> 74: 2. Create a Symbolic link targeting the created test directory.
> 75: ex : mklink /D c:\\link c:\\target
> 76: 3. In JFileChooser, navigate to "link" created directed.
…navigate to directory where you created the link. In this example, to C:\ drive.
Please use the capital C: for the drive.
-------------
Changes requested by aivanov (Reviewer).
PR: https://git.openjdk.org/jdk/pull/9597
More information about the client-libs-dev
mailing list