-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
1.4.2, 6
-
generic, x86
-
generic, windows_xp
FULL PRODUCT VERSION :
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
The java.io.File toURL() method generates file URL's that seem to not conform to the governing RFC 1738 (section 3.10), which specifies. "A file URL takes the form: file://<host>/<path>", where <host> may be left empty for local file systems, example (windows):
file:///C:/temp/text.txt
The toURL() method of java.io.File generates a file URL of the form:
"file:<host>/<path>" (with host being left empty), example:
file:/C:/temp/text.txt
Refer to http://www.faqs.org/rfcs/rfc1738.html
This issue is not in any way related to Bug ID: 4723726 (except that both may be generating non-conforming file URL's).
After looking at the source for java.net.URL and java.net.URI, I have
identified the cause of the invalid (non-conformant) file URL's being
generated.
The errors occur in the URL.toString()/URI.toString() underlying
methods, i.e. java.net.URLStreamHandler.toExternalForm(URL u) and
java.net.URI.defineString() respectively.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the minimal application listed below and observe its console output.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Output of the above application expected to be:
File C:\temp\text.txt has url file:///C:/temp/text.txt
(note the triple slash after file:)
ACTUAL -
Output of the above application is:
File C:\temp\text.txt has url file:/C:/temp/text.txt
(note the single slash after file:)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
public class FileUrl {
public static void main(String[] args) throws MalformedURLException {
File file = new File("C:/temp/text.txt");
URL url = file.toURL();
System.out.println("File " + file + " has url " + url);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
This bug generally has no implications, although some protocol handlers may treat the file URL's generated by java.io.toURL() as having an illegal syntax.
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
The java.io.File toURL() method generates file URL's that seem to not conform to the governing RFC 1738 (section 3.10), which specifies. "A file URL takes the form: file://<host>/<path>", where <host> may be left empty for local file systems, example (windows):
file:///C:/temp/text.txt
The toURL() method of java.io.File generates a file URL of the form:
"file:<host>/<path>" (with host being left empty), example:
file:/C:/temp/text.txt
Refer to http://www.faqs.org/rfcs/rfc1738.html
This issue is not in any way related to Bug ID: 4723726 (except that both may be generating non-conforming file URL's).
After looking at the source for java.net.URL and java.net.URI, I have
identified the cause of the invalid (non-conformant) file URL's being
generated.
The errors occur in the URL.toString()/URI.toString() underlying
methods, i.e. java.net.URLStreamHandler.toExternalForm(URL u) and
java.net.URI.defineString() respectively.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the minimal application listed below and observe its console output.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Output of the above application expected to be:
File C:\temp\text.txt has url file:///C:/temp/text.txt
(note the triple slash after file:)
ACTUAL -
Output of the above application is:
File C:\temp\text.txt has url file:/C:/temp/text.txt
(note the single slash after file:)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
public class FileUrl {
public static void main(String[] args) throws MalformedURLException {
File file = new File("C:/temp/text.txt");
URL url = file.toURL();
System.out.println("File " + file + " has url " + url);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
This bug generally has no implications, although some protocol handlers may treat the file URL's generated by java.io.toURL() as having an illegal syntax.
- relates to
-
JDK-6385002 all Desktop methods (browse, open etc.) only accept canonical path
-
- Open
-
-
JDK-6360233 Deprecated toURL method does not handle UNC path
-
- Closed
-