JDK-8331109 : JFileChooser throws NullpointerException after JDK-8293862 in Windows
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 21,22
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows
  • CPU: generic
  • Submitted: 2024-04-25
  • Updated: 2024-04-29
  • Resolved: 2024-04-26
Related Reports
Duplicate :  
Relates :  
Description
Steps to reproduce:
1. Run the attached manual test(JFileChooserCrashTest.java) with Windows L&F.
java -Dswing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel JFileChooserCrashTest.java
2. When the FileChooser opens up, navigate to 'Downloads' and try to open it.
3. It throws NullpointerException and the user will not be able to navigate to anything else(attached screenshot) and there is no workaround for this, need to close the application.
4. This is reproducible only in Windows and specifically with Windows L&F.
5. This is reproducible when the user tries to open certain system folders(with an image icon) like 'Downloads', 'Libraries' etc. 
6. This seems to be a regression introduced by the fix of JDK-8293862 in JDK 21 b07.
7. This crash is not reproducible with JDK 21 b06 or below, but another issue is reproducible there addressed by JDK-8293862 -> "Exception in thread "AWT-EventQueue-0" java.nio.file.InvalidPathException: Illegal char <:> at index 0: ::{031E4825-7B94-4DC3-B131-E946B44C8DD5}".
8. It is not reproducible in JDK 23, possibly fixed by JDK-8320692.
Comments
JDK-8320692 is now backported to 21.0.5-oracle.
29-04-2024

Exception stack trace: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Cannot invoke "java.awt.Image.getWidth(java.awt.image.ImageObserver)" because "retVal" is null at java.desktop/sun.awt.shell.Win32ShellFolder2$MultiResolutionIconImage.getResolutionVariant(Win32ShellFolder2.java:1459) at java.desktop/sun.awt.shell.Win32ShellFolder2$MultiResolutionIconImage.getBaseImage(Win32ShellFolder2.java:1438) at java.desktop/java.awt.image.AbstractMultiResolutionImage.getProperty(AbstractMultiResolutionImage.java:140) at java.desktop/javax.swing.ImageIcon.<init>(ImageIcon.java:255) at java.desktop/javax.swing.ImageIcon.<init>(ImageIcon.java:241) at java.desktop/javax.swing.filechooser.FileSystemView.getSystemIcon(FileSystemView.java:252) at java.desktop/com.sun.java.swing.plaf.windows.WindowsFileChooserUI$WindowsFileView.getIcon(WindowsFileChooserUI.java:1352) at java.desktop/javax.swing.JFileChooser.getIcon(JFileChooser.java:1613) at java.desktop/sun.swing.FilePane$FileRenderer.getListCellRendererComponent(FilePane.java:1635) at java.desktop/javax.swing.plaf.basic.BasicListUI.updateLayoutState(BasicListUI.java:1444) at java.desktop/javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(BasicListUI.java:1394) at java.desktop/javax.swing.plaf.basic.BasicListUI$Handler.valueChanged(BasicListUI.java:2815) at java.desktop/javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:231) at java.desktop/javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:206) at java.desktop/javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:258) at java.desktop/javax.swing.DefaultListSelectionModel.setAnchorSelectionIndex(DefaultListSelectionModel.java:824) at java.desktop/sun.swing.FilePane.clearSelection(FilePane.java:1869) at java.desktop/sun.swing.FilePane$5.contentsChanged(FilePane.java:702) at java.desktop/javax.swing.AbstractListModel.fireContentsChanged(AbstractListModel.java:127) at java.desktop/javax.swing.plaf.basic.BasicDirectoryModel.fireContentsChanged(BasicDirectoryModel.java:194) at java.desktop/javax.swing.plaf.basic.BasicDirectoryModel$DoChangeContents.run(BasicDirectoryModel.java:560) at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714) at java.base/java.security.AccessController.doPrivileged(AccessController.java:400) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
26-04-2024

[~aivanov] PFB my reply for your queries. 1. Could you run your test case with '-ea -esa' options? [1] When I enabled assertions, it gives the below AssertionError, Exception in thread "AWT-EventQueue-0" java.lang.AssertionError: There are null icons in the MRI variants map at java.desktop/sun.awt.shell.Win32ShellFolder2$MultiResolutionIconImage.<init>(Win32ShellFolder2.java:1414) at java.desktop/sun.awt.shell.Win32ShellFolder2.lambda$getIcon$0(Win32ShellFolder2.java:1201) at java.desktop/sun.awt.shell.Win32ShellFolderManager2$ComInvoker.invoke(Win32ShellFolderManager2.java:630) at java.desktop/sun.awt.shell.ShellFolder.invoke(ShellFolder.java:532) at java.desktop/sun.awt.shell.ShellFolder.invoke(ShellFolder.java:518) at java.desktop/sun.awt.shell.Win32ShellFolder2.getIcon(Win32ShellFolder2.java:1154) at java.desktop/sun.awt.shell.Win32ShellFolder2$15.call(Win32ShellFolder2.java:1128) at java.desktop/sun.awt.shell.Win32ShellFolder2$15.call(Win32ShellFolder2.java:1067) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) at java.desktop/sun.awt.shell.Win32ShellFolderManager2$ComInvoker$1.run(Win32ShellFolderManager2.java:599) at java.base/java.lang.Thread.run(Thread.java:1583) 2. Do you have an .exe file without a custom icon in your Downloads folder? Yes, and I tested it again by copying a couple of .exe files to another folder and now when I open that folder also, the same issue is very much reproducible. 3. I have added the exception stackt race as a new comment and made the bug public.
26-04-2024

When the test case is run with the assertions enabled, the failed assertion is exactly the same as that in JDK-8320692 [1]. You confirm that your Downloads folder contain .exe files without custom icons. Given these two facts above, this bug is exact duplicate of JDK-8320692. It'll be resolved as soon as JDK-8320692 is backported into 21u. [1] https://bugs.openjdk.org/browse/JDK-8320692?focusedId=14641646&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14641646
26-04-2024

I'm pretty sure it is duplicate of JDK-8320692 which is a regression introduced by JDK-8293862. Could you run your test case with '-ea -esa' options? [1] Do you have an .exe file without a custom icon in your Downloads folder? Could you attach the exception stack trace as a comment? Or rather add it into the bug description. [1] https://bugs.openjdk.org/browse/JDK-8320692?focusedId=14641646&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14641646
25-04-2024

assigning to owner of JDK-8293862 fix
25-04-2024