Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8283621

Write a regression test for CCC4400728

    XMLWordPrintable

Details

    Backports

      Description

        Write a regression test for JDK-4400728
        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

            Activity

              People

                mvs Manukumar V S
                mvs Manukumar V S
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: