Per Bothner writes: > Andrew Haley wrote: > > > Would it be OK to > > special-case "file" URIs so that "file:/" is rewritten to ""file:///" ? > > Maybe for the URL class, but I don't think so for the URI class. > The difference is the getAuthority method. My reading is that it should > return null for "file:/" and "" for "file:///". But I haven't tested > what JDK does - and it wouldn't surprise me if the URI and URL classes > are different in this respect.
It seems to me that the constructors for URLs and URIs are quite different, and their description is separate. The difference between JDK and Classpath seems to be restricted to the case where a URL is created with an enclosing context that is another URL. Here's a tiny test case: import java.net.*; public class TestURLs { public static void main (String[] argv) throws Exception { URL url = new URL(argv[0]); URL url2 = new URL(url, argv[1], null); System.err.println(url2); } } The case that we get wrong is this one: $ java TestURLs 'jar:file:/ejbjars/ws.jar!/META-INF/wsdl/ssbEndpoint.wsdl' 'jar:file:ejbjars/ws.jar!/META-INF/wsdl/ssbEndpoint.wsdl' jar:file:ejbjars/ws.jar!/META-INF/wsdl/ssbEndpoint.wsdl $ gij TestURLs 'jar:file:/ejbjars/ws.jar!/META-INF/wsdl/ssbEndpoint.wsdl' 'jar:file:ejbjars/ws.jar!/META-INF/wsdl/ssbEndpoint.wsdl' jar:file:/ejbjars/ws.jar!/META-INF/wsdl/file:ejbjars/ws.jar!/META-INF/wsdl/ssbEndpoint.wsdl So, in that case the context should be ignored. In fact, it seems like the context is ignored for all "jar:file" and "file:" URLs: $ java TestURLs 'http://ejbjars/ws.jar' 'jar:file:foo!/META-INF/wsdl/ssbEndpoint.wsdl' jar:file:foo!/META-INF/wsdl/ssbEndpoint.wsdl $ java TestURLs 'http://ejbjars/' 'jar:file:foo!/META-INF/wsdl/ssbEndpoint.wsdl' jar:file:foo!/META-INF/wsdl/ssbEndpoint.wsdl $ java TestURLs 'jar:file:/ejbjars/ws.jar!/META-INF/wsdl/ssbEndpoint.wsdl' file:foo file:foo But in the case of a URL that is not qualified with any protocol at all we need the context: $ java TestURLs 'jar:file:/ejbjars/ws.jar!/META-INF/wsdl/ssbEndpoint.wsdl' foo jar:file:/ejbjars/ws.jar!/META-INF/wsdl/foo Classpath gets that right too. So, the only thing we seem to get wrong is the parsing of a 'jar:file:' URL when a 'jar:' context is supplied. Andrew. _______________________________________________ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches