-
Bug
-
Resolution: Fixed
-
P3
-
1.4.2, 5.0
-
b46
-
x86
-
windows_98, windows_xp
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2130449 | 5.0u5 | Praveen G | P3 | Closed | Fixed | b04 |
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
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
- backported by
-
JDK-2130449 JFileChooser: Linked dir (directory-shortcut) failing (dir w/target.lnk inside)
- Closed
- relates to
-
JDK-4356160 JFileChooser doesn't support shortcuts (.lnk files)
- Resolved
-
JDK-5086831 JFileChooser.getSelectedFile() returns incorrect path on Windows network folder
- Resolved
-
JDK-6180936 REGRESSION: JFileChooser not resolves NetworkNeighbourhood Links in 1.5.0
- Resolved