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

Accessing Removable drives pops up dialog box from java native code

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.3.1, 1.3.1_03
    • core-libs
    • x86
    • windows_2000



      Name: ddT132432 Date: 09/25/2001


      java version "1.3.1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
      Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)

      Accessing Removable Drives through java.io.File causes java.exe to pop up a
      dialog when no disk is inserted saying the drive is not available. This does
      not happen on all computers. A description of an example computer is included
      below. The problem is somewhere in the java native code, maybe in
      FileSystem.checkAccess ?? One developer thinks it may only be a problem on
      machines with SCSI devices, since it does not occur on all our machines, though
      I have not verified that this is the case.

      /******** START SOURCE **********************************************/

      import java.io.File;
      import java.util.Properties;
      import java.util.Iterator;
      import java.util.Set;

      public class RootFileAccess {

          public static void main(String args[]) {

              Properties props = System.getProperties();
              Set pSet = props.keySet();

              Iterator iter = pSet.iterator();
              while(iter.hasNext()) {
                  String next = (String)iter.next();
                  System.out.println(next + " == " + (String)props.get(next));
              }

              File[] roots = File.listRoots();

              System.out.println("=================================");
              for(int x=0; x<roots.length; x++) {
                  System.out.println("Drive " + x + ": " + roots[x].getAbsolutePath());
                  try {
                      System.out.println("Drive " + x + ": " + roots [x].getCanonicalPath());
                  } catch(Exception exc) {
                      System.out.println("Drive " + x + ": threw exception on cannonical path" );
                      exc.printStackTrace();
                  }

                  try {
                      if(roots[x].canRead()) {
                          System.out.println("Drive " + x + " is readable");
                      } else {
                          System.out.println("Drive " + x + " is NOT readable");
                      }
                  } catch(Exception exc) {
                      System.out.println("Drive " + x + ": threw exception on read check" );
                      exc.printStackTrace();
                  }

                  try {
                      if(roots[x].exists()) {
                          System.out.println("Drive " + x + " exists");
                      } else {
                          System.out.println("Drive " + x + " does NOT exist");
                      }
                  } catch(Exception exc) {
                      System.out.println("Drive " + x + ": threw exception on existence check" );
                      exc.printStackTrace();
                  }

                  try {
                      if(roots[x].isDirectory()) {
                          System.out.println("Drive " + x + " is directory");
                      } else {
                          System.out.println("Drive " + x + " is NOT directory");
                      }
                  } catch(Exception exc) {
                      System.out.println("Drive " + x + ": threw exception on directory check" );
                      exc.printStackTrace();
                  }
                  System.out.println("===================================");

              }

          }
      }
      /********** END SOURCE *********************************************/

      /***** START OUTPUT *********/

      D:\temp>java RootFileAccess
      java.runtime.name == Java(TM) 2 Runtime Environment, Standard Edition
      sun.boot.library.path == d:\java\jdk1.3.1\jre\bin
      java.vm.version == 1.3.1-b24
      java.vm.vendor == Sun Microsystems Inc.
      java.vendor.url == http://java.sun.com/
      path.separator == ;
      java.vm.name == Java HotSpot(TM) Client VM
      file.encoding.pkg == sun.io
      java.vm.specification.name == Java Virtual Machine Specification
      user.dir == D:\temp
      java.runtime.version == 1.3.1-b24
      java.awt.graphicsenv == sun.awt.Win32GraphicsEnvironment
      os.arch == x86
      java.io.tmpdir == C:\DOCUME~1\BMORIA~1\LOCALS~1\Templine.separator ==

      java.vm.specification.vendor == Sun Microsystems Inc.
      java.awt.fonts ==
      os.name == Windows 2000
      java.library.path == d:\java\jdk1.3.1\bin;.;C:\WINNT\System32;C:\WINNT;d:\usr\lo
      cal\bin;d:\usr\bin;d:\java\jdk1.3.1\bin;d:\home\bmoriarty\bin;d:\usr\local\vim\v
      im60aq;d:\java\jdk1.3.1\jre\bin\classic;d:\java\jakarta-ant-1.3\bin;d:\usr\perlbin;C:\WINNT\system32;d:\programs\DISA\dii_dev\bin;d:\home\bmoriarty\src\polexis
      \xistm\bin;d:\home\bmoriarty\src\viking\bin;d:\home\bmoriarty\src\polexis\memtes
      t\bin
      java.specification.name == Java Platform API Specification
      java.class.version == 47.0
      os.version == 5.0
      user.home == C:\Documents and Settings\bmoriarty
      user.timezone ==
      java.awt.printerjob == sun.awt.windows.WPrinterJob
      file.encoding == Cp1252
      java.specification.version == 1.3
      java.class.path == .
      user.name == bmoriarty
      java.vm.specification.version == 1.0
      java.home == d:\java\jdk1.3.1\jre
      user.language == en
      java.specification.vendor == Sun Microsystems Inc.
      awt.toolkit == sun.awt.windows.WToolkit
      java.vm.info == mixed mode
      java.version == 1.3.1
      java.ext.dirs == d:\java\jdk1.3.1\jre\lib\ext
      sun.boot.class.path == d:\java\jdk1.3.1\jre\lib\rt.jar;d:\java\jdk1.3.1\jre\libi18n.jar;d:\java\jdk1.3.1\jre\lib\sunrsasign.jar;d:\java\jdk1.3.1\jre\classes
      java.vendor == Sun Microsystems Inc.
      file.separator == java.vendor.url.bug == http://java.sun.com/cgi-bin/bugreport.cgi
      sun.io.unicode.encoding == UnicodeLittle
      sun.cpu.endian == little
      user.region == US
      sun.cpu.isalist == pentium i486 i386
      =================================================================
      Drive 0: A:Drive 0: threw exception on cannonical path
      java.io.IOException: The device is not ready
              at java.io.Win32FileSystem.canonicalize(Native Method)
              at java.io.File.getCanonicalPath(File.java:440)
              at RootFileAccess.main(RootFileAccess.java:30)
      Drive 0 is NOT readable
      Drive 0 does NOT exist
      Drive 0 is NOT directory
      =================================================================
      Drive 1: C:Drive 1: C:Drive 1 is readable
      Drive 1 exists
      Drive 1 is directory
      =================================================================
      Drive 2: D:Drive 2: D:Drive 2 is readable
      Drive 2 exists
      Drive 2 is directory
      =================================================================
      Drive 3: E:Drive 3: threw exception on cannonical path
      java.io.IOException: The device is not ready
              at java.io.Win32FileSystem.canonicalize(Native Method)
              at java.io.File.getCanonicalPath(File.java:440)
              at RootFileAccess.main(RootFileAccess.java:30)
      Drive 3 is NOT readable
      Drive 3 does NOT exist
      Drive 3 is NOT directory
      =================================================================
      Drive 4: F:Drive 4: threw exception on cannonical path
      java.io.IOException: The device is not ready
              at java.io.Win32FileSystem.canonicalize(Native Method)
              at java.io.File.getCanonicalPath(File.java:440)
              at RootFileAccess.main(RootFileAccess.java:30)
      Drive 4 is NOT readable
      Drive 4 does NOT exist
      Drive 4 is NOT directory
      =================================================================
      Drive 5: I:Drive 5: I:Drive 5 is readable
      Drive 5 exists
      Drive 5 is directory
      =================================================================

      D:\temp>

      /******* END OUTPUT *********/

      /******* START CONFIG INFO *********/

      popups appear on A:\ and e:\ on the machine in the previous example, below
      is a description of some of the drives on that machine.

      a:type=Floppy disk drive
      driver=c:\winnt\System32\DRIVERS\flpydisk.sys

      c:\ and d:type=FUJITSU MAJ3182MP SCSI Disk Device
      driver provider=Microsoft

      e:type=IOMEGA ZIP 250
      driver provider=MIcrosoft

      f:type=SONY CD-RW CRX160E
      driver=c:\WINNT\System32\DRIVERS\cdrom.sys

      /******** END CONFIG INFO ***************/
      (Review ID: 131512)
      ======================================================================

            mr Mark Reinhold
            ddressersunw Daniel Dresser (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: