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

java.io.File has inconsistent behavior of the empty pathname

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.2.1
    • core-libs
    • x86
    • windows_95



      Name: vi73552 Date: 04/21/99


      the canonical pathname string for the empty pathname
      object file=new File("") is computed using the system property
      user.dir, but NOT the access to the underlying file, at least
      when calling the method list()
      So:
      //----------- UserDirTest
      package bugs;
      import java.io.*;

      public class UserDirTest {
      public static void main(String[] args) throws IOException {
      File dir= new File("");
      System.out.println("User directory is: "+dir.getCanonicalPath());
      System.out.println("Content is:");
      String[] names= dir.list();
      for(int i= 0;i<names.length;i++) {
      System.out.println("\t"+names[i]);
      }
      }
      }

      produces something like:
      C:\Java\Projects\classes>java -Djava.compiler=NONE bugs.UserDirTest
      User directory is: C:\Java\Projects\classes
      Content is:
      Exception in thread "main" java.lang.NullPointerException:
      at bugs.UserDirTest.main(UserDirTest.java:18)

      instead of:
      User directory is: C:\Java\Projects\classes
      Content is:
      bugs
      (Review ID: 56975)
      ======================================================================

            nsanjeevsunw Naveen Sanjeeva (Inactive)
            vasya Vassili Igouchkine (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: