Bug 49236 - JAR indexing does not have any benefits and can cause some harm
JAR indexing does not have any benefits and can cause some harm
Product: Tomcat 5
Classification: Unclassified
Component: Unknown
PC Windows XP
: P2 normal (vote)
: ---
Assigned To: Tomcat Developers Mailing List
Depends on:
  Show dependency tree
Reported: 2010-04-30 05:49 UTC by Konstantin Kolinko
Modified: 2010-05-14 02:41 UTC (History)
0 users

2010-04-30_tc6_bug49236.patch (820 bytes, patch)
2010-04-30 06:03 UTC, Konstantin Kolinko
Details | Diff
2010-04-30_tc55_bug49236.patch (14.46 KB, patch)
2010-04-30 06:13 UTC, Konstantin Kolinko
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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 [1], blog article that describes main problems [2], ANT documentation on JAR task and especially the nested "indexjars" element as described there [3].

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 [4], or official specification from PKWARE [5].

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 [2] 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.

[1] JAR Index specification - JDK 1.5

[2] To Use or not to Use Jar Index - A blog article

[3] Jar Task - Apache ANT Documentation

[4] ZIP (file format) - Wikipedia

Comment 1 Konstantin Kolinko 2010-04-30 06:03:35 UTC
Created attachment 25381 [details]

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]

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.