JDK-8305597 : Remove JAR Index
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 21
  • Submitted: 2023-04-04
  • Updated: 2023-04-08
  • Resolved: 2023-04-08
Related Reports
CSR :  
Description
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.


Comments
Moving to Approved.
08-04-2023

There are no changes to the API docs, it's just the JAR file spec. There will be some follow-up work to update the jar man page, nothing else.
05-04-2023

Moving to Provisional, not Approved. Just wanted to check no additional API updates/notes were needed in or around java.util.jar.JarFile or jdk.jartool for this feature.
05-04-2023

This "feature" has been problematic for a long time. We originally hoped to remove it in JDK 9 but didn't get to it. The proposal in JDK 18 to remove changed to disabling it by default instead. There has been no feedback since it was disabled.
05-04-2023

I have attached the JAR File spec changes
04-04-2023