JDK-5102604 : JFileChooser: Linked dir (directory-shortcut) failing (dir w/target.lnk inside)
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.2,5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_98,windows_xp
  • CPU: x86
  • Submitted: 2004-09-15
  • Updated: 2005-08-04
  • Resolved: 2005-08-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6
5.0u5Fixed 6 b46Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
Name: gm110360			Date: 09/15/2004


FULL PRODUCT VERSION :
j2re-1_4_2_05-b04

ADDITIONAL OS VERSION INFORMATION :
Windows Millennium [ versio 4.90.3000 ]

A DESCRIPTION OF THE PROBLEM :
I don't have access to a US version of Windows ME, so some of the translations might be wrong. Where I am in doubt, I include the Finnish name in parenteheses.
JFileChooser cannot handle folder shortcuts. Not shortcuts to a folder, but folder-shortcuts (Kansio-pikakuvake). These special directories are real directories on DOS side, with a target.lnk file inside them. If you open such a directory on the windows side, you get into the directory it points to, not the DOS directory. JFileChooser seems to behave correctly, as the filesystem view
one gets is the contents of the target directory. However, if one selects this directory in JFileChooser, the DOS path gets returned, not the path to the target directory.
I observed this behavior with a UNC directory (\\server\drive\directory) as the target directory. This is because the occasion when this occurs in real usage is when the user selects the directory shortcut in the network neighborhood menu (verkkoympM-^O����ristM-^O����), where each shared directory is listed as a directory shortcut.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Start JDialog, select a file under Network Neighborhood (verkkoympM-^O����ristM-^O����) which
points to a directory on another machine. The filename returned is the local C:\\... path,
not the UNC filepath.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Same behavior as windows itself, i.e. return the UNC path.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.JFileChooser;
import java.io.File;
import java.io.IOException;

public class JFileChooserBugDemo {
    public static void main(String argv[]) {
        JFileChooser fc = new JFileChooser();
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int reply = fc.showDialog(null, "Pick a directory.");
        File file = null;
        if (reply != JFileChooser.APPROVE_OPTION || (file = fc.getSelectedFile()) == null) {
            System.exit(0);
        }
        try {
            System.err.println("You chose '" + file.getCanonicalPath() + "'");
        } catch (IOException ex) {
            System.err.println(ex.getMessage());
        }
        System.exit(0);
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Write win32 code and link with JNI. Doesn't seem like a good thing.
(Incident Review ID: 286655) 
======================================================================

Cu reports this issue on the following platforms as well:

Windows 2000 SP4 (Professional and Server), Windows XP SP1 and SP2 and Windows 2003 Server.
###@###.### 2005-06-09 18:50:49 GMT

Comments
EVALUATION Added test in Win32ShellFolder2.listFiles() to only return an empty list for objects that are links *and* do not have the native FOLDER attribute.
04-08-2005

SUGGESTED FIX ###@###.### 2005-06-21 20:59:31 GMT
21-06-2005

EVALUATION Reproducible with FileChooserDemo in mustang-b02 when selecting directories only. Kiitos paljon. ###@###.### 2004-09-16 This is not a regression. The problem is related to, but not identical to bug 6180936. This bug is about not being able to choose folders in "My Network Places" (NetHood) when in DIRECTORIES_ONY mode. This will be a bit difficult to fix, as we have no high level API to distinguish between links to folders and folders with links. The affected method is BasicFileChooserUI.valueChanged() which in turn is affected by FileSystemView.isFileSystem(). ###@###.### 2005-06-21 20:59:31 GMT
21-06-2005

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang
25-09-2004