On Tue, 29 Mar 2022 20:48:58 GMT, Sergey Bylokhov <s...@openjdk.org> wrote:
>> Write a regression test for >> [JDK-4400728](https://bugs.openjdk.java.net/browse/JDK-4400728) >> >> Issue: >> JFileChooser constructors by default set current directory to the "Desktop" >> value on Windows, >> but should use 'My Documents' property instead, also user.home for unix >> platforms. >> >> javadoc says: >> "public JFileChooser() >> Constructs a JFileChooser pointing to the user's default directory. This >> default depends on the operating system. It is typically the 'My Documents' >> folder on Windows, and the user's home directory on Unix. >> " >> See this >> https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/swing/JFileChooser.html#%3Cinit%3E() >> >> Testing: >> 1. Tested using Mach5(20 times per platform) in macos,linux and windows and >> got all pass. >> 2. Tested in original failed Java version and the fixed version; >> Java 1.4.0 -> Test Failed. >> $ j2sdk1.4.0/bin/java JFileChooserDefaultDirectoryTest >> java.lang.NullPointerException >> at java.io.File.<init>(File.java:180) >> at >> sun.awt.shell.Win32ShellFolder.listFiles(Win32ShellFolder.java:517) >> at >> sun.awt.shell.Win32ShellFolderManager.get(Win32ShellFolderManager.java:152) >> at sun.awt.shell.ShellFolder.get(ShellFolder.java:208) >> at >> javax.swing.plaf.metal.MetalFileChooserUI.installComponents(MetalFileChooserUI.java:310) >> at >> javax.swing.plaf.basic.BasicFileChooserUI.installUI(BasicFileChooserUI.java:130) >> at >> javax.swing.plaf.metal.MetalFileChooserUI.installUI(MetalFileChooserUI.java:152) >> at javax.swing.JComponent.setUI(JComponent.java:445) >> at javax.swing.JFileChooser.updateUI(JFileChooser.java:1701) >> at javax.swing.JFileChooser.setup(JFileChooser.java:345) >> at javax.swing.JFileChooser.<init>(JFileChooser.java:320) >> at javax.swing.JFileChooser.<init>(JFileChooser.java:273) >> at >> JFileChooserDefaultDirectoryTest.main(JFileChooserDefaultDirectoryTest.java:15) >> Exception in thread "main" >> >> Java 1.5.0 -> Test Passed. >> $ jdk1.5.0/bin/java JFileChooserDefaultDirectoryTest >> UserHome dir = C:\Users\jpgansible >> Test Passed >> >> Java 1.8.0 -> Test Passed. >> $ jdk1.8.0_331/bin/java JFileChooserDefaultDirectoryTest >> UserHome dir = C:\Users\jpgansible >> Test Passed > > test/jdk/javax/swing/JFileChooser/4400728/JFileChooserDefaultDirectoryTest.java > line 46: > >> 44: .startsWith("windows"); >> 45: if (isWindows) { >> 46: if (actualDefaultDirectory.endsWith("Documents")) { > > Based on this PR https://github.com/openjdk/jdk/pull/7983 can we check just > the "Documents" string? As Windows 8.x is still supported, isn't it better to do it like this, for safer side? ------------- PR: https://git.openjdk.java.net/jdk/pull/7942