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

FileSystemView isComputerNode and other is* methods do not work.

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Version:
      6
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0_13"
      Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
      Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)

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

      A DESCRIPTION OF THE PROBLEM :
      As per the documentation:
      "Used by UI classes to decide whether to display a special icon for a computer node, e.g. "My Computer" or a network server. The default implementation has no way of knowing, so always returns false."

      ... isComputerNode is broken and is therefore useless.

      There seems to be no good way to enumerate the fixed disks in a computer

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Call isComputerNode on the "My Computer" node.
      Call isDrive on the "C:\" node.
      etc...


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package filesystemtest;

      import java.io.File;
      import javax.swing.filechooser.FileSystemView;

      public class Main {

          public static void main(String[] args) {
              FileSystemView fsv = FileSystemView.getFileSystemView();
              File [] roots = fsv.getRoots();

              String os = System.getProperty("os.name");
              if (os.startsWith("Windows")) {
                  // "Desktop" is the one root on Windows - so lets look inside
                  // My goal is to get a list of hard drives...
                  roots = fsv.getFiles(roots[0], true);
                  File r = roots[0];
                  System.err.println(fsv.getSystemDisplayName(r)
                              + (fsv.isComputerNode(r)? " is" : " is NOT" )
                              + " the Computer Node.");
              }
          }
      }


      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Assume that the nodes are returned in a known order (first and only root on Windows is "Desktop" - first child of it is "My Computer")

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              igor Igor Nekrestyanov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Imported:
                Indexed: