Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5056422

REGRESSION: File.isDirectory() true for links to non-dirs: listFiles crashes

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Duplicate
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_2000, windows_xp

      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)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              leifs Leif Samuelsson (Inactive)
              Reporter:
              gmanwanisunw Girish Manwani (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: