Details
-
Enhancement
-
Resolution: Fixed
-
P4
-
8, 11, 17, 18, 19
-
b17
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8290458 | 17.0.5-oracle | Dukebot | P4 | Resolved | Fixed | b03 |
JDK-8291674 | 17.0.5 | Goetz Lindenmaier | P4 | Resolved | Fixed | b01 |
JDK-8290503 | 11.0.17-oracle | Dukebot | P4 | Resolved | Fixed | b03 |
JDK-8291680 | 11.0.17 | Goetz Lindenmaier | P4 | Resolved | Fixed | b01 |
JDK-8290623 | 8u351 | Dukebot | P4 | Resolved | Fixed | b03 |
Description
Issue:
JFileChooser constructors by default set current directory to the "Desktop" value on Windows,
but should use user.home property instead.
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
Attachments
Issue Links
- backported by
-
JDK-8290458 Write a regression test for CCC4400728
- Resolved
-
JDK-8290503 Write a regression test for CCC4400728
- Resolved
-
JDK-8290623 Write a regression test for CCC4400728
- Resolved
-
JDK-8291674 Write a regression test for CCC4400728
- Resolved
-
JDK-8291680 Write a regression test for CCC4400728
- Resolved
- relates to
-
JDK-8283642 JavaDoc of JFileChooser() need to be updated for default directory in Windows
- Resolved
-
JDK-4400728 JFileChooser constructors set incorrect default directory on Windows.
- Resolved
- links to
-
Commit openjdk/jdk11u-dev/15335203
-
Commit openjdk/jdk17u-dev/016e5004
-
Commit openjdk/jdk/632825c6
-
Review openjdk/jdk11u-dev/1291
-
Review openjdk/jdk17u-dev/613
-
Review openjdk/jdk/7942