United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-5086147 File,URI,URL conversions are strange for UNC path
JDK-5086147 : File,URI,URL conversions are strange for UNC path

Details
Type:
Bug
Submit Date:
2004-08-12
Status:
Resolved
Updated Date:
2012-10-09
Project Name:
JDK
Resolved Date:
2005-03-18
Component:
core-libs
OS:
windows_2000
Sub-Component:
java.net
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
5.0u1
Fixed Versions:

Related Reports
Backport:
Relates:
Relates:
Relates:

Sub Tasks

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



Hardware and Software, Engineered to Work Together