-
Bug
-
Resolution: Fixed
-
P3
-
1.1
-
1.1.5
-
x86
-
windows_95
-
Verified
Name: mc57594 Date: 02/07/97
When FileInputStream is used to access the directory in a simple
listing program, using getProperty("user.dir") to obtain an
argument for the list() method of FileInputStream results in
an empty list being returned (apparently by the Security Manager).
This was found in an application and NOT in an applet where such
behaviour would be expected. The same results occur with the
Symantec Virtual Machine, J++, and the 1.0.2 SDK. The problem
does not exist on Windows NT nor would I expect a Sun Unix Platform.
The resulting accesses to the empty array produced by list(String[] s)
result in a NullPointerException being thrown.
This appears to be a chink in the platform indepence armour of Java.
Please comment on your findings, I am at ###@###.### or
at ###@###.###.
company - McDonnel Douglas , email - ###@###.###
======================================================================
Here is the reporter's sample program, received via email:
/* ls lists the contents of the "current directory".
* There is a known bug in this program that when the current
* directory is a root directory, a NullPointerException will
* be thrown when the length of the String array holding the
* directory listing is accessed. This does not occur on a
* non root directory for any drive. Also, this does not
* occur when the application is run on Windows NT. The
* bug appears to be related to Windows 95. The File class
* seems to call the Security manager class and then return
* an empty list. This has been the case for the Symantic
* Virtual machine 2.00b21 as well as for the Sun
* SDK V1.1B3 for Win95.
*
* John McKinney 2/2/97
*
*/
import java.util.*;
import java.io.*;
public class ls {
String sCurrentDir;
String[] saListing;
File fCurrentListing;
public ls (){
this.sCurrentDir = new String(System.getProperty("user.dir"));
this.fCurrentListing = new File(this.sCurrentDir);
System.out.println(this.sCurrentDir);
this.saListing = new String[fCurrentListing.list().length];
System.arraycopy(this.fCurrentListing.list(),0,this.saListing,0,this.saListing.length);
}
public static void main (String[] args){
ls lsDir = new ls();
for (int i=0; i<lsDir.saListing.length;i++)
System.out.println(lsDir.saListing[i]);
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
max.spivak@Eng 1997-08-01
Please see my comment submitted to bug 4065189.