United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6317789 REGRESSION: JFileChooser() hangs when encountering a shortcut to the desktop
JDK-6317789 : REGRESSION: JFileChooser() hangs when encountering a shortcut to the desktop

Details
Type:
Bug
Submit Date:
2005-08-30
Status:
Resolved
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2006-05-10
Component:
client-libs
OS:
windows_xp
Sub-Component:
javax.swing
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
5.0
Fixed Versions:

Related Reports

Sub Tasks

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

ADDITIONAL OS VERSION INFORMATION :
Windows XP  Service Pack 2 (also happens /w service pack 1)

EXTRA RELEVANT SYSTEM CONFIGURATION :
Not hardware specific

A DESCRIPTION OF THE PROBLEM :
Java hangs completely when JFileChooser() is called when a shortcut to the desktop is present on the desktop of Windows XP.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :

In windows XP right-click on the desktop,  select  "new" from the popup menu then select "shortcut:". In the popup-dialog select "browse", then select the topmost item in the tree "desktop". Select ok. This will create a shortcut to the desktop on the desktop. I have used a shortcut like this for quick access to my desktop icons from a popup window (works well when assigned a hotkey).

Next, create a simple java program that simply calls the default constructor of JFileChooser  - ie:


 public class Test {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JFileChooser fileChooser = new JFileChooser();
            };
        });
    }
}

When run with JDK 5.0 this program will hang. However, if you delete the desktop link the program runs to completion. If you run this program with JDK 1.4 it works fine - even with the desktop  link.

As a final note, the bug is not present if you set the "useShellFolder" property to false, ie:

                JFileChooser fileChooser = new JFileChooser() {
                    public void updateUI() {
                        putClientProperty("FileChooser.useShellFolder", Boolean.FALSE);
                        super.updateUI();
                    }
                };



EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I did not expect java to hang.
ACTUAL -
Java hung and the program had to be terminated by task manager.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class Test {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                // java will hang here if a particular shortcut is present on the desktop
                JFileChooser fileChooser = new JFileChooser();
            };
        });
    }
}

See steps above for creating the shortcut on the desktop.
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Delete the desktop link (see steps for recreating) or add

    putClientProperty("FileChooser.useShellFolder", Boolean.FALSE);

to all JFileChooserClasses.

Release Regression From : 1.4.2
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

Release Regression From : 1.4.2
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

                                    

Comments
EVALUATION

Need to verify that bug is present in Mustang beta.
                                     
2005-11-08
EVALUATION

The cause is that native Win32ShellFolder2.copyFirstPIDLEntry() can return 0 if the ID list is empty, and this is the case for a shortcut to the Desktop created on the Desktop itself. This situation was not handled in Win32ShellFolder2.createShellFolderFromRelativePIDL().

It didn't appear earlier because JFileChooser didn't supported shortcuts. Since  ###@###.### added the support for shortcuts as the fix for 4356160, it became possible to do that trick with shortcut looping.
                                     
2006-03-23
SUGGESTED FIX

In Win32ShellFolder2.createShellFolderFromRelativePIDL(), break the cycle if native Win32ShellFolder2.copyFirstPIDLEntry() returns 0 (see the implementation of the latter, it has a branch that returns 0 if the ID list is empty).
                                     
2006-03-23



Hardware and Software, Engineered to Work Together