|Summary:||JAR indexing does not have any benefits and can cause some harm|
|Product:||Tomcat 5||Reporter:||Konstantin Kolinko <knst.kolinko>|
|Component:||Unknown||Assignee:||Tomcat Developers Mailing List <dev>|
Description Konstantin Kolinko 2010-04-30 05:49:29 UTC
In TC 7, 6, 5.5 build scripts in several places we use <jar index="true"/>, which creates META-INF/INDEX.LIST file in the JAR. I should say that a) The JAR Index feature is designed to speed up location and download of other *.jar files. It is not intended to be used on a single file. See specification , blog article that describes main problems , ANT documentation on JAR task and especially the nested "indexjars" element as described there . One should use <indexjars> element inside the <jar> task to exploit this feature properly. b) It does not speed up processing of a single JAR. First, a JAR file already has an index, "Central Directory" - see picture in Wikipedia article , or official specification from PKWARE . AFAIK, in Sun JRE this central directory is always read and loaded into memory before any random-access query on the file is performed, such as ZipFile#getEntry(String). Second, an URLClassLoader has to consider JARs mentioned in the Index file. It incurs some overhead, though I have not measured how much it is. c) Using Index file can conflict with "Class-Path" entry of the manifest. See  for explanation. Also the text of the index file starts with the name of the current JAR file. I suppose that it can have some consequences if the file is renamed. Based on the above, we have to use index="false" on all our <jar> tasks. Links:  JAR Index specification - JDK 1.5 http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html#JAR%20Index  To Use or not to Use Jar Index - A blog article http://javahowto.blogspot.com/2006/08/to-use-or-not-to-use-jar-index.html  Jar Task - Apache ANT Documentation http://ant.apache.org/manual/CoreTasks/jar.html  ZIP (file format) - Wikipedia http://en.wikipedia.org/wiki/ZIP_%28file_format%29#Technical_information  ZIP APPNOTE - PKWARE http://www.pkware.com/support/zip-application-note
Comment 1 Konstantin Kolinko 2010-04-30 06:03:35 UTC
Created attachment 25381 [details] 2010-04-30_tc6_bug49236.patch Fixed in trunk in r939612. I am attaching patch for TC6.
Comment 2 Konstantin Kolinko 2010-04-30 06:13:32 UTC
Created attachment 25382 [details] 2010-04-30_tc55_bug49236.patch Patch for TC 5.5.
Comment 3 Konstantin Kolinko 2010-04-30 06:29:32 UTC
Fixed in trunk, proposed for 6.0 and 5.5
Comment 4 Konstantin Kolinko 2010-05-14 02:41:14 UTC
Fixed in 6.0, 5.5, will be in 6.0.27, 5.5.30.