JDK-6477862 : Local files with anchors do not work with Desktop.browse()0
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-10-03
  • Updated: 2011-02-16
  • Resolved: 2006-10-04
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0-rc"
Java(TM) SE Runtime Environment (build 1.6.0-rc-b100)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b100, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

EXTRA RELEVANT SYSTEM CONFIGURATION :
Tested with the following browsers set as the default:
Firefox 1.5.0.7
IE 6.0
IE 7.0.5700.6CO

A DESCRIPTION OF THE PROBLEM :
Using the Desktop.browse() method to browse to a URL of a local file with an anchor does not navigate to the anchor. The browser is opened to the local file, but the top of the file is displayed and the anchor is striped off of the URL.

Example:
Desktop.browse(new URI("file:///C:/foo/bar.html#anchor"));

I would expect this to open the browser to the file C:/foo/bar.html and auto-navigate to the anchor "anchor". It opens the brower to the file C:/foo/bar.html, but the top of the file is displayed.

Please note this works when the URL is using http to locate the file.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create an HTML file on local filesystem with an embedded anchor.
2. Use the Desktop.browse() method to open the local HTML file to the anchor.
3. The local HTML file will be displayed, but the anchor will be ignored.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect this to open the browser to the file and auto-navigate to the anchor.
ACTUAL -
It opens the brower to the file, but the top of the file is displayed, and the anchor is removed from the URL.


REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
On Windows:

...
final String[] cmd = {"rundll32", "url.dll,FileProtocolHandler", "\"" + url + "\""};
            try {
                runtime.exec(cmd);
            } catch (Throwable e) {
                app.exception(e, false);
            }
...

This works when Firefox is the default browser. It kind of works when IE 6.0 is the default (works when IE is NOT already open, if already open, get actual behavior above). It does not work at all for IE 7.

Comments
EVALUATION URI from the description of this bug is not correct: Desktop.browse(new URI("file:///C:/foo/bar.html#anchor")); This URI uses file:// protocol, so everything after the protocol specifier is interpreted as a local file: C:/foo/bar.html#anchor. One can see that this is not a correct file name. If you specify http:// as the protocol for URI, the anchor would be handled correctly as http protocol supports anchors.
04-10-2006