RFR: 8283621: Write a regression test for CCC4400728

Manukumar V S mvs at openjdk.java.net
Thu Mar 24 15:29:20 UTC 2022


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

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

Commit messages:
 - 8283621: Write a regression test for CCC4400728

Changes: https://git.openjdk.java.net/jdk/pull/7942/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=7942&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8283621
  Stats: 71 lines in 1 file changed: 71 ins; 0 del; 0 mod
  Patch: https://git.openjdk.java.net/jdk/pull/7942.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/7942/head:pull/7942

PR: https://git.openjdk.java.net/jdk/pull/7942



More information about the client-libs-dev mailing list