JDK-5056422 : REGRESSION: File.isDirectory() true for links to non-dirs: listFiles crashes
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000,windows_xp
  • CPU: x86
  • Submitted: 2004-06-02
  • Updated: 2004-06-04
  • Resolved: 2004-06-04
Related Reports
Duplicate :  
Duplicate :  
Description

Name: gm110360			Date: 06/02/2004


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

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
File.isDirectory() is returning true for shell folder links that point to
non-directories. Doing a listFiles() on such a file causes an
InternalError to be thrown. This looks related to 5009755.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run code. Navigate to a directory with a shortcut pointing to a
normal file.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expect normal file navigation.
ACTUAL -
InternalError is thrown.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.InternalError: Unable to bind C:\Documents and Settings\Larry\Desktop\access-4-free (2).lnk to parent
	at sun.awt.shell.Win32ShellFolder2.getIShellFolder(Unknown Source)
	at sun.awt.shell.Win32ShellFolder2.listFiles(Unknown Source)
	at sun.awt.shell.ShellFolder.listFiles(Unknown Source)
	at FileBug5$1.getIcon(FileBug5.java:11)
	at javax.swing.plaf.metal.MetalFileChooserUI$DirectoryComboBoxRenderer.getListCellRendererComponent(Unknown Source)
	at javax.swing.plaf.basic.BasicListUI.updateLayoutState(Unknown Source)
	at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(Unknown Source)
	at javax.swing.plaf.basic.BasicListUI$Handler.valueChanged(Unknown Source)
	at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source)
	at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source)
	at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source)
	at javax.swing.DefaultListSelectionModel.changeSelection(Unknown Source)
	at javax.swing.DefaultListSelectionModel.changeSelection(Unknown Source)
	at javax.swing.DefaultListSelectionModel.setSelectionInterval(Unknown Source)
	at javax.swing.JList.setSelectedIndex(Unknown Source)
	at javax.swing.plaf.basic.BasicComboPopup.setListSelection(Unknown Source)
	at javax.swing.plaf.basic.BasicComboPopup.access$300(Unknown Source)
	at javax.swing.plaf.basic.BasicComboPopup$Handler.itemStateChanged(Unknown Source)
	at javax.swing.JComboBox.fireItemStateChanged(Unknown Source)
	at javax.swing.JComboBox.selectedItemChanged(Unknown Source)
	at javax.swing.JComboBox.contentsChanged(Unknown Source)
	at javax.swing.AbstractListModel.fireContentsChanged(Unknown Source)
	at javax.swing.plaf.metal.MetalFileChooserUI$DirectoryComboBoxModel.setSelectedItem(Unknown Source)
	at javax.swing.plaf.metal.MetalFileChooserUI$DirectoryComboBoxModel.addItem(Unknown Source)
	at javax.swing.plaf.metal.MetalFileChooserUI$DirectoryComboBoxModel.access$800(Unknown Source)
	at javax.swing.plaf.metal.MetalFileChooserUI.doDirectoryChanged(Unknown Source)
	at javax.swing.plaf.metal.MetalFileChooserUI.access$1100(Unknown Source)
	at javax.swing.plaf.metal.MetalFileChooserUI$5.propertyChange(Unknown Source)
	at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
	at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
	at java.awt.Component.firePropertyChange(Unknown Source)
	at javax.swing.JFileChooser.setCurrentDirectory(Unknown Source)
	at javax.swing.JFileChooser.<init>(Unknown Source)
	at javax.swing.JFileChooser.<init>(Unknown Source)
	at FileBug5$1.<init>(FileBug5.java:9)
	at FileBug5.main(FileBug5.java:7)



REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
   import javax.swing.Icon;
   import javax.swing.JFileChooser;
   import java.io.File;
    
    public class FileBug5 {
       public static void main(String[] args) {
         JFileChooser fc =
                new JFileChooser() {
                   public Icon getIcon(File f) {
                     if(f.isDirectory())
                        f.listFiles();
                     return super.getIcon(f);
                  }
               };
         fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
         fc.showOpenDialog(null);
      }
   }
---------- END SOURCE ----------

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.

(Incident Review ID: 275541) 
======================================================================

Comments
EVALUATION I can reproduce this bug with shortcuts that really point to directories. A possible solution would be to have listFiles() return an empty array, since shortcuts can't be parents to files. The shortcuts are never actually returned to the application, i.e. they can be traversed but not chosen. I can not reproduce this problem with shortcuts that point to non-directories. Please provide information about what the target is for the shortcut named "C:\Documents and Settings\Larry\Desktop\access-4-free (2)". Thanks. ###@###.### 2004-06-02 ===============================================================================
02-06-2004