JDK-5086147 : File,URI,URL conversions are strange for UNC path
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 5.0u1
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2004-08-12
  • Updated: 2012-10-09
  • Resolved: 2005-03-18
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.
JDK 6
6 betaFixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
See: 
Exception in thread "main" java.lang.IllegalArgumentException: URI has an authority component
	at java.io.File.<init>(File.java:340)

caused by code:

File f = new File ("//SERVER/MyDocuments/USER/DIR/");        
new File (f.toURI().toURL().toURI()); /* file://SERVER/MyDocuments/USER/DIR */


but following code is OK:
new File (f.toURI()); /* file:////SERVER/MyDocuments/USER/DIR */

Its fragile, not mentioning that URI.normalize () complicates it even more (file:/SERVER/MyDocuments/USER/DIR)

Comments
EVALUATION After investigation, I think problem falls into 2 categories: One is URI.normalize() is removing too many slashes, as bug 4723726 says. The other is for any URI u, following identities not hold - u.toURL().toURI().equals(u) The buggy code may be java.net.URLStreamHandler.parseURL(). Anyway, UNC name is just used in windows. Is it safe to slightly adjust class URL's behavior to fix this bug? ###@###.### 2004-11-29 10:48:57 GMT
2004-11-29