JDK-6887710 : Jar index should avoid putting META-INF in the INDEX.LIST
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 6u16
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2009-10-02
  • Updated: 2013-11-01
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
6u18Fixed 7 b130Fixed
"META-INF" will be included in the jar index (INDEX.LIST) if there is any file directly in META-INF/ directory, other than the manifest or the index itself. This can cause unnecessary downloading of indexed jars in cases where the classloader is being used to try and find a service that may be defined in META-INF/.

A good example of this is custom fonts in javafx. Fonts are define in META-INF/fonts.mf and the classloader is used to search for these fonts. Now suppose you have a fully indexed javafx application and indexed javafx runtime. If your application inadvertantly tries to use an undefined font it will force all of the jars (both eager and lazy) to be downloaded as it searches for the fonts.mf in each jar.

java.util.ServiceLoader does suffer from this problem, but is slightly different as it uses the META-INF/serivces directory. If a jar defines any service then it may be downloaded only to find out that the service it defines is not actually the one that is required. It would be better to index the actual services and not just META-INF/services.

EVALUATION New system property added to enable this functionality. /** * true if, and only if, sun.misc.JarIndex.metaInfFilenames is set to true. * If true, the names of the files in META-INF, and its subdirectories, will * be added to the index. Otherwise, just the directory names are added. */ private static final boolean metaInfFilenames = "true".equals(System.getProperty("sun.misc.JarIndex.metaInfFilenames")); JDK 7 changeset: Changeset: 0f5dc2fc81b1 Author: chegar Date: 2011-02-03 11:56 +0000 URL: http://hg.openjdk.java.net/jdk7/tl/jdk/rev/0f5dc2fc81b1 6887710: Jar index should avoid putting META-INF in the INDEX.LIST Reviewed-by: michaelm ! src/share/classes/sun/misc/JarIndex.java + test/sun/misc/JarIndex/metaInfFilenames/Basic.java + test/sun/misc/JarIndex/metaInfFilenames/jarA/META-INF/services/my.happy.land + test/sun/misc/JarIndex/metaInfFilenames/jarA/a/A.java + test/sun/misc/JarIndex/metaInfFilenames/jarA/com/message/spi/MessageService.java + test/sun/misc/JarIndex/metaInfFilenames/jarB/META-INF/JAVA2.DS + test/sun/misc/JarIndex/metaInfFilenames/jarB/META-INF/services/no.name.service + test/sun/misc/JarIndex/metaInfFilenames/jarB/b/B.java + test/sun/misc/JarIndex/metaInfFilenames/jarC/META-INF/fonts.mf + test/sun/misc/JarIndex/metaInfFilenames/jarC/META-INF/fonts/Company-corporate.ttf + test/sun/misc/JarIndex/metaInfFilenames/jarC/META-INF/fonts/kidpr.ttf + test/sun/misc/JarIndex/metaInfFilenames/jarC/META-INF/services/com.message.spi.MessageService + test/sun/misc/JarIndex/metaInfFilenames/jarC/my/impl/StandardMessageService.java

EVALUATION Files directly under META-INF should be added explicitly (not just their directory name). This way when the index is queried if the exact resource is not available the jar will be skipped and not unnecesarily searched.