JDK-4765316 : REGRESSION: FileSystemView.getFiles() no longer works with relative paths
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-10-18
  • Updated: 2004-09-02
  • Resolved: 2004-09-02
Related Reports
Relates :  
Description

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) 
======================================================================

Comments
EVALUATION The FileSystemView class is only intended for use with JFileChooser. I am lowering the priority to P4 since this bug doesn't affect the functionality of JFileChooser. ###@###.### 2002-10-18 ----------------------------------------- This bug is not reproducible in 1.5.0 after fix for 4869950. ###@###.### 2004-09-02
18-10-2002