Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5102604

JFileChooser: Linked dir (directory-shortcut) failing (dir w/target.lnk inside)

    Details

    • Subcomponent:
    • Resolved In Build:
      b46
    • CPU:
      x86
    • OS:
      windows_98, windows_xp

      Backports

        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

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  leifs Leif Samuelsson (Inactive)
                  Reporter:
                  gmanwanisunw Girish Manwani (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: