-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
1.4.0
-
x86
-
windows_2000
Name: sv35042 Date: 10/18/2002
FULL PRODUCT VERSION :
java version "1.4.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
FileSystemView g_objSysView =
FileSystemView.getFileSystemView();
This used to work pre JDK 1.4:
File arrFiles[] = g_objSysView.getFiles
(g_objSysView.createFileObject("..\\db\\actions\\",true);
In JDK 1.4, arrFiles is zero length with a relative path,
unless I use the following line of code instead.
File arrFiles[] = (g_objSysView.createFileObject
("..\\db\\actions\\")).listFiles();
REGRESSION. Last worked in version 1.3.1
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. See the code sample
2.
3.
EXPECTED VERSUS ACTUAL BEHAVIOR :
I can see no reason why I cannot use this construct:
File arrFiles[] = g_objSysView.getFiles
(g_objSysView.createFileObject(CFG_DIR),true);
versus this construct to obtain a list of files
File arrFiles[] = (g_objSysView.createFileObject
(CFG_DIR)).listFiles();
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.*;
import java.util.*;
import javax.swing.filechooser.*;
public class test
{
public static void main(String []args)
{
System.out.println("cwd: " + System.getProperty("user.dir"));
FileSystemView g_objSysView = FileSystemView.getFileSystemView();
// CFG_DIR is a string containing a relative path (e.g., "..\\parent1\\child1")
// This used to work pre JDK 1.4:
// File arrFiles[] = g_objSysView.getFiles(g_objSysView.createFileObject
(CFG_DIR),true);
// I have to use this in JDK 1.4 to obtain the desired result:
File arrFiles[] = (g_objSysView.createFileObject(CFG_DIR)).listFiles();
File objFile;
if(arrFiles.length < 1)
System.out.println("length of zero!");
else
{
for(int i = 0; i < arrFiles.length; i++)
{
objFile = arrFiles[i];
if(objFile.isDirectory())
System.out.println("Dir: " + objFile.getName());
else
System.out.println("File: " + objFile.getName
());
}
}
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
File arrFiles[] = (g_objSysView.createFileObject
(CFG_DIR)).listFiles();
Release Regression From : 1.4
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
(Review ID: 159258)
======================================================================
- relates to
-
JDK-4869950 NPE if JFileChooser.setCurrentDirectory() called twice with non-canonical file
- Closed