JDK-4917110 : Bug in sun.awt.shell.Win32ShellFolder2 causes a WindowsFileChooserUI to crash
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2003-09-04
  • Updated: 2003-09-04
  • Resolved: 2003-09-04
Related Reports
Duplicate :  
Description

Name: jk109818			Date: 09/04/2003


FULL PRODUCT VERSION :
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)


FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
In class sun.awt.shell.Win32ShellFolder2 the method makeIcon(long, boolean) was implemented incorrectly - it supposes that the first paramter should be always greater then zero. Actually, the first parameter is a Windows icon handle singed extened to long (with a cdq assembler command). So, if the handle was, for instance, e9120665 (that is absolutely correct handle), the first parameter would be ffffffffe9120665, and the method makeIcon(long, boolean) will return null. As a result, some items in the filechooser (in Windows L&F) may have incorrect icons (for example - simple folder icon for the disk item in shortcuts combobox), or even NullPointerException will occur (for example, if such handle would be returned for the My Documents folder). This is also the cause of bugs 4806285 and probably 4711700.
The solution is very simple:
[current implementation]
    private Image makeIcon(long l, boolean flag)
    {
        if(l > 0L)
        {
... //create icon
        }
        return null;
    }
[should be]
    private Image makeIcon(long l, boolean flag)
    {
        if(l!=0L && l!=-1L)
        {
... //create icon
        }
        return null;
    }

The bug is reproduced occasionally, as it depends on Windows, whether they would return the icon handle (HICON) with the high-order bit 1 (which will reproduce the bug) or 0.





STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create the file chooser with the Windows L&F and look at the icons for the items in combobox.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Good icons.
ACTUAL -
Icons for some disks may be simple folder icons, not a proper Windows icons for the disks.
Occasionally, the NullPointerException may occur.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
The usual error message is as follows:
java.lang.NullPointerException
        at javax.swing.ImageIcon.<init>(ImageIcon.java:161)
        at javax.swing.ImageIcon.<init>(ImageIcon.java:147)
        at
com.sun.java.swing.plaf.windows.WindowsFileChooserUI$ShortCutPanel.<init>(WindowsFileChooserUI.java:603)
...

REPRODUCIBILITY :
This bug can be reproduced occasionally.
(Incident Review ID: 192239) 
======================================================================