-
Bug
-
Resolution: Fixed
-
P3
-
21, 22
-
- 11-na
- 17-bp
- CPU24_07-critical-SQE-OK
- CPU24_07-critical-approved
- additional-information-received
- bugdb_36591721
- dcspn
- jdk17u-fix-request
- jdk17u-fix-yes
- jdk21u-fix-request
- jdk21u-fix-yes
- jdk22u-fix-SQE-ok
- jdk22u-fix-request
- jdk22u-fix-yes
- regression
- regression_8293862
- reproducer-yes
- sn_160
- sn_161
- webbug
-
b07
-
b07
-
x86_64
-
windows
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8331323 | 22.0.2 | Alexey Ivanov | P4 | Resolved | Fixed | b05 |
JDK-8327223 | 21.0.5-oracle | Alexey Ivanov | P4 | Resolved | Fixed | b01 |
JDK-8332077 | 21.0.4-oracle | Alexey Ivanov | P3 | Resolved | Fixed | b06 |
JDK-8333142 | 21.0.4 | Martin Doerr | P3 | Resolved | Fixed | b05 |
JDK-8331409 | 17.0.13-oracle | Alexey Ivanov | P4 | Resolved | Fixed | b01 |
JDK-8333631 | 17.0.13 | Martin Doerr | P3 | Resolved | Fixed | b01 |
The Open file dialog hangs when selecting a folder that contains .exe files with the default Windows exe icon.
Someone has already reported this bug (https://bugs.java.com/bugdatabase/view_bug?bug_id=8297529​), and it was marked as resolved. However, when I download the latest JDK version (jdk 21.0.1), the issue still persists. The root cause is that the 'newIcon' variable becomes null in the 'getIcon' function of the 'Win32ShellFolder2.class.'
The NullPointerException occurs as follows:
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.paintImpl(BasicListUI.java:330)
at java.desktop/javax.swing.plaf.basic.BasicListUI.paint(BasicListUI.java:306)
at java.desktop/javax.swing.plaf.ComponentUI.update(ComponentUI.java:161)
at java.desktop/javax.swing.JComponent.paintComponent(JComponent.java:852)
at java.desktop/javax.swing.JComponent.paint(JComponent.java:1128)
at java.desktop/javax.swing.JComponent.paintToOffscreen(JComponent.java:5318)
at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBufferedFPScales(RepaintManager.java:1720)
at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1629)
at java.desktop/javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1569)
at java.desktop/javax.swing.RepaintManager.paint(RepaintManager.java:1336)
at java.desktop/javax.swing.JComponent._paintImmediately(JComponent.java:5266)
at java.desktop/javax.swing.JComponent.paintImmediately(JComponent.java:5076)
at java.desktop/javax.swing.RepaintManager$4.run(RepaintManager.java:878)
at java.desktop/javax.swing.RepaintManager$4.run(RepaintManager.java:861)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.desktop/javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:861)
at java.desktop/javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:834)
at java.desktop/javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:784)
at java.desktop/javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1897)
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.pumpEventsForFilter(EventDispatchThread.java:117)
at java.desktop/java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:191)
at java.desktop/java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:236)
at java.desktop/java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:234)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:319)
at java.desktop/java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:234)
at java.desktop/java.awt.Dialog.show(Dialog.java:1079)
at java.desktop/javax.swing.JFileChooser.showDialog(JFileChooser.java:771)
at java.desktop/javax.swing.JFileChooser.showOpenDialog(JFileChooser.java:668)
at demo.showOpenFileDialog(demo.java:90)
at demo.access$0(demo.java:51)
at demo$1.actionPerformed(demo.java:28)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2314)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:407)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6621)
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3398)
at java.desktop/java.awt.Component.processEvent(Component.java:6386)
at java.desktop/java.awt.Container.processEvent(Container.java:2266)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4996)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4828)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4575)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2780)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4828)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:775)
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.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:98)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:747)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
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:744)
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)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Open the Open file dialog.
2. Navigate to a folder containing .exe files with the default Windows exe icon.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The Open file dialog should not hang, and all files in the specified folder should load and be selectable within the dialog.
ACTUAL -
Throws NullPointerException
---------- BEGIN SOURCE ----------
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.filechooser.FileNameExtensionFilter;
public class demo extends JFrame {
private JButton buttonBrowse;
public demo() {
super("Demo File Type Filter");
setLayout(new FlowLayout());
buttonBrowse = new JButton("Browse...");
buttonBrowse.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
showOpenFileDialog();
}
});
getContentPane().add(buttonBrowse);
setSize(300, 100);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) { }
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new demo();
}
});
}
private void showOpenFileDialog() {
// Contain some exe files with the default Windows exe icon
File fileTest = new File("D:/Downloads/Test");
JFileChooser fileChooser = new JFileChooser();
fileChooser.setCurrentDirectory(fileTest);
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("EXE File","exe"));
int result = fileChooser.showOpenDialog(this);
if (result == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile();
System.out.println("Selected file: " + selectedFile.getAbsolutePath());
}
}
}
---------- END SOURCE ----------
- backported by
-
JDK-8332077 Null icon returned for .exe without custom icon
- Resolved
-
JDK-8333142 Null icon returned for .exe without custom icon
- Resolved
-
JDK-8333631 Null icon returned for .exe without custom icon
- Resolved
-
JDK-8327223 Null icon returned for .exe without custom icon
- Resolved
-
JDK-8331323 Null icon returned for .exe without custom icon
- Resolved
-
JDK-8331409 Null icon returned for .exe without custom icon
- Resolved
- duplicates
-
JDK-8327175 NPE JFileChooser Windows L&F opening Windows folder
- Closed
-
JDK-8331109 JFileChooser throws NullpointerException after JDK-8293862 in Windows
- Closed
- relates to
-
JDK-8282526 Default icon is not painted properly
- Resolved
-
JDK-8293862 javax/swing/JFileChooser/8046391/bug8046391.java failed with 'Cannot invoke "java.awt.Image.getWidth(java.awt.image.ImageObserver)" because "retVal" is null'
- Resolved
-
JDK-8182043 Access to Windows Large Icons
- Resolved
- links to
-
Commit openjdk/jdk17u-dev/a0c72d04
-
Commit openjdk/jdk21u-dev/2971cb57
-
Commit openjdk/jdk22u/7381b848
-
Commit openjdk/jdk/6212264c
-
Review openjdk/jdk17u-dev/2527
-
Review openjdk/jdk21u-dev/614
-
Review openjdk/jdk22u/167
-
Review openjdk/jdk/17475