Details
-
Bug
-
Resolution: Fixed
-
P2
-
7
Description
The specs for java.net.URL claims to support JAR URLs:
"Protocol handlers for the following protocols are guaranteed to exist on the search path :- http, https, ftp, file, and jar"
(http://download.oracle.com/javase/6/docs/api/java/net/URL.html#URL%28java.lang.String,%20java.lang.String,%20int,%20java.lang.String%29)
The syntax of a JAR URL is described in JarURLConnection:
jar:<url>!/{entry}
Thus the following URLs are expected to be equal:
jar:<url1>!/{entry1}
jar:<url2>!/{entry2}
- if url1 equals url2 and entry1 equals entry2.
However this is not the case in the following example:
=======================================================================
String innerHttpSpec1_1 = "http://MyHost.ru/classes.jar";
String innerHttpSpec1_2 = "http://myhost.ru/classes.jar";
URL innerHttpUrl1_1 = new URL(innerHttpSpec1_1);
URL innerHttpUrl1_2 = new URL(innerHttpSpec1_2);
URL jarUrl1_1 = new URL("jar:" + innerHttpSpec1_1 + "!/i18n.properties");
URL jarUrl1_2 = new URL("jar:" + innerHttpSpec1_2 + "!/i18n.properties");
System.out.println("innerHttpUrl1_1: " + innerHttpUrl1_1);
System.out.println("innerHttpUrl1_2: " + innerHttpUrl1_2);
System.out.println("innerHttpUrl1_1.equals(innerHttpUrl1_2): " +
innerHttpUrl1_1.equals(innerHttpUrl1_2));
System.out.println("jarUrl1_1: " + jarUrl1_1);
System.out.println("jarUrl1_2: " + jarUrl1_2);
System.out.println("jarUrl1_1.equals(jarUrl1_2): " +
jarUrl1_1.equals(jarUrl1_2));
-----------------------------------------------------------------------
prints:
innerHttpUrl1_1: http://MyHost.ru/classes.jar
innerHttpUrl1_2: http://myhost.ru/classes.jar
innerHttpUrl1_1.equals(innerHttpUrl1_2): true
jarUrl1_1: jar:http://MyHost.ru/classes.jar!/i18n.properties
jarUrl1_2: jar:http://myhost.ru/classes.jar!/i18n.properties
jarUrl1_1.equals(jarUrl1_2): *false*
=======================================================================
As well as in the following:
=======================================================================
String innerFileSpec1_1 = "file:///C:/Windows/classes.jar";
String innerFileSpec1_2 = "file:/C:/Windows/classes.jar";
URL innerFileUrl1_1 = new URL(innerFileSpec1_1);
URL innerFileUrl1_2 = new URL(innerFileSpec1_2);
URL jarUrl1_1 = new URL("jar:" + innerFileSpec1_1 + "!/i18n.properties");
URL jarUrl1_2 = new URL("jar:" + innerFileSpec1_2 + "!/i18n.properties");
System.out.println("innerFileUrl1_1: " + innerFileUrl1_1);
System.out.println("innerFileUrl1_2: " + innerFileUrl1_2);
System.out.println("innerFileUrl1_1.equals(innerFileUrl1_2): " +
innerFileUrl1_1.equals(innerFileUrl1_2));
System.out.println("jarUrl1_1: " + jarUrl1_1);
System.out.println("jarUrl1_2: " + jarUrl1_2);
System.out.println("jarUrl1_1.equals(jarUrl1_2): " +
jarUrl1_1.equals(jarUrl1_2));
-----------------------------------------------------------------------
prints:
innerFileUrl1_1: file:/C:/Windows/classes.jar
innerFileUrl1_2: file:/C:/Windows/classes.jar
innerFileUrl1_1.equals(innerFileUrl1_2): true
jarUrl1_1: jar:file:///C:/Windows/classes.jar!/i18n.properties
jarUrl1_2: jar:file:/C:/Windows/classes.jar!/i18n.properties
jarUrl1_1.equals(jarUrl1_2): *false*
=======================================================================
(The sample code is attached)
"Protocol handlers for the following protocols are guaranteed to exist on the search path :- http, https, ftp, file, and jar"
(http://download.oracle.com/javase/6/docs/api/java/net/URL.html#URL%28java.lang.String,%20java.lang.String,%20int,%20java.lang.String%29)
The syntax of a JAR URL is described in JarURLConnection:
jar:<url>!/{entry}
Thus the following URLs are expected to be equal:
jar:<url1>!/{entry1}
jar:<url2>!/{entry2}
- if url1 equals url2 and entry1 equals entry2.
However this is not the case in the following example:
=======================================================================
String innerHttpSpec1_1 = "http://MyHost.ru/classes.jar";
String innerHttpSpec1_2 = "http://myhost.ru/classes.jar";
URL innerHttpUrl1_1 = new URL(innerHttpSpec1_1);
URL innerHttpUrl1_2 = new URL(innerHttpSpec1_2);
URL jarUrl1_1 = new URL("jar:" + innerHttpSpec1_1 + "!/i18n.properties");
URL jarUrl1_2 = new URL("jar:" + innerHttpSpec1_2 + "!/i18n.properties");
System.out.println("innerHttpUrl1_1: " + innerHttpUrl1_1);
System.out.println("innerHttpUrl1_2: " + innerHttpUrl1_2);
System.out.println("innerHttpUrl1_1.equals(innerHttpUrl1_2): " +
innerHttpUrl1_1.equals(innerHttpUrl1_2));
System.out.println("jarUrl1_1: " + jarUrl1_1);
System.out.println("jarUrl1_2: " + jarUrl1_2);
System.out.println("jarUrl1_1.equals(jarUrl1_2): " +
jarUrl1_1.equals(jarUrl1_2));
-----------------------------------------------------------------------
prints:
innerHttpUrl1_1: http://MyHost.ru/classes.jar
innerHttpUrl1_2: http://myhost.ru/classes.jar
innerHttpUrl1_1.equals(innerHttpUrl1_2): true
jarUrl1_1: jar:http://MyHost.ru/classes.jar!/i18n.properties
jarUrl1_2: jar:http://myhost.ru/classes.jar!/i18n.properties
jarUrl1_1.equals(jarUrl1_2): *false*
=======================================================================
As well as in the following:
=======================================================================
String innerFileSpec1_1 = "file:///C:/Windows/classes.jar";
String innerFileSpec1_2 = "file:/C:/Windows/classes.jar";
URL innerFileUrl1_1 = new URL(innerFileSpec1_1);
URL innerFileUrl1_2 = new URL(innerFileSpec1_2);
URL jarUrl1_1 = new URL("jar:" + innerFileSpec1_1 + "!/i18n.properties");
URL jarUrl1_2 = new URL("jar:" + innerFileSpec1_2 + "!/i18n.properties");
System.out.println("innerFileUrl1_1: " + innerFileUrl1_1);
System.out.println("innerFileUrl1_2: " + innerFileUrl1_2);
System.out.println("innerFileUrl1_1.equals(innerFileUrl1_2): " +
innerFileUrl1_1.equals(innerFileUrl1_2));
System.out.println("jarUrl1_1: " + jarUrl1_1);
System.out.println("jarUrl1_2: " + jarUrl1_2);
System.out.println("jarUrl1_1.equals(jarUrl1_2): " +
jarUrl1_1.equals(jarUrl1_2));
-----------------------------------------------------------------------
prints:
innerFileUrl1_1: file:/C:/Windows/classes.jar
innerFileUrl1_2: file:/C:/Windows/classes.jar
innerFileUrl1_1.equals(innerFileUrl1_2): true
jarUrl1_1: jar:file:///C:/Windows/classes.jar!/i18n.properties
jarUrl1_2: jar:file:/C:/Windows/classes.jar!/i18n.properties
jarUrl1_1.equals(jarUrl1_2): *false*
=======================================================================
(The sample code is attached)