JDK-6668272 : BasicFileChooserUI.java throw FileNotFoundException with set own FileSystemView
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2008-02-27
  • Updated: 2011-02-16
  • Resolved: 2010-06-15
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_04"
Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Windows XP SP2 32bit

A DESCRIPTION OF THE PROBLEM :
Change in 1.6.0_04 Java BUG ID: 6560349  break own implemention of FileSystemView.

In BasicFileChooserUI.java  "changeDirectory(File dir)" you always call
"ShellFolder shellFolder = ShellFolder.getShellFolder(dir);".
If FileSystemView is used by another filesystem like JDBC or IBM i5, then ShellFolder throws an exception.

The ClientProperty  "FileChooser.useShellFolder" is not used.

Same problem in Java SE 6 update N.

ACTUAL -
In JFileChooser I can not go into  directory with mouse doubleclick.

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
 private void changeDirectory(File dir) {

JFileChooser fc = getFileChooser();

Boolean prop = Boolean)fc.getClientProperty("FileChooser.useShellFolder");
if (prop == null) {
	prop = Boolean.TRUE;
}

// Traverse shortcuts on Windows
if (dir != null && prop.booleanValue()) {
    try {
                ShellFolder shellFolder = ShellFolder.getShellFolder(dir);
                if (shellFolder.isLink()) {
                    File linkedTo = shellFolder.getLinkLocation();
                    if (linkedTo != null && fc.isTraversable(linkedTo)) {
                        dir = linkedTo;
                    } else {
                        return;
                    }
                }
	    } catch (FileNotFoundException ex) {
		return;
	    }
	}
	fc.setCurrentDirectory(dir);
        if (fc.getFileSelectionMode() == JFileChooser.FILES_AND_DIRECTORIES &&
            fc.getFileSystemView().isFileSystem(dir)) {

            setFileName(dir.getAbsolutePath());
        }
    }