Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8305597

Remove JAR Index

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 21
    • core-libs
    • None
    • behavioral
    • low
    • The compatibility risk is low. If a JAR file contains an index then it will be ignored, as it has done since JDK 18. The jar tool will continue to generate an index, if invoked to do so.
    • add/remove/modify command line option
    • SE

      Summary

      The JAR Index mechanism is a legacy optimization from early JDK releases to allow downloading of JAR files to be postponed when loading applets or other classes over the network. The feature has been disabled by default since Java 18. Time has come to remove the feature from the Java runtime and also to add a warning to the jar tool when the -i/--generate-index option is used.

      Problem

      The JAR Index feature does not interact well with other features and has several long standing issues:

      • The JAR index file META-INF/INDEX.LIST is ignored in modular JARs.

      • The JAR index is not reliable when be used with Multi-Release JAR files, e.g. when the versioned section has classes/resources in "new packages".

      • URLClassLoader::findResources does not locate resources in more than one JAR file when a JAR index is present.

      • JarInputStream::getManifest can not return the Manifest because the index is stored as the first entry in the JAR file.

      It was hoped to deprecate or remove JAR Index in Java 9 but it didn't happen. In JDK 18, the support at runtime is to ignore JAR index files by default with a system property to re-enable if needed. There has been no feedback on this change.

      Solution

      • Drop JAR Index from the JAR file spec
      • Remove the run-time support for JAR index and the JDK-specific system property jdk.net.URLClassPath.enableJarIndex
      • Deprecate jar tool -i/--generate-index option. The --help output will print:
       -i, --generate-index=FILE  Generate index information for the specified jar
                                   archives. This option is deprecated and may be 
                                   removed in a future release.
      • Using jar --generate-index or jar -i will print a warning:
          The JAR index (META-INF/INDEX.LIST) is ignored at run-time since JDK 18
          Warning: The --generate-index/-i option is deprecated, and may be ignored or removed in a future release

      Specification

      Update the JAR File specification to remove:

      • INDEX.LIST and its description from the "The META-INF directory" section
      • The "JAR Index" section

      A release note is planned. The release note will document that the system property jdk.net.URLClassPath.enableJarIndex has been removed, that the jar tool option to generate an index is deprecated, and that the jar tool will emit a warning if invoked to generate an index.

            eirbjo Eirik Bjørsnøs
            eirbjo Eirik Bjørsnøs
            Alan Bateman, Lance Andersen, Mandy Chung
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: