United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6887710 Jar index should avoid putting META-INF in the INDEX.LIST
6887710 : Jar index should avoid putting META-INF in the INDEX.LIST

Details
Type:
Bug
Submit Date:
2009-10-02
Status:
Closed
Updated Date:
2011-03-08
Project Name:
JDK
Resolved Date:
2011-03-08
Component:
core-libs
OS:
generic
Sub-Component:
java.net
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
6u16
Fixed Versions:
7

Related Reports
Backport:

Sub Tasks

Description
"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.

                                    

Comments
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
                                     
2011-02-03
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.
                                     
2009-10-02



Hardware and Software, Engineered to Work Together