In the context of JDK-8152190 it was noticed that [sun.misc.]InvalidJarIndexException
is mentioned in the Jar File Specification [1], but it is an internal type. There is only one
static code reference to InvalidJarIndexException in the JDK source, and that is in the
URLClassPath implementation, where it creates a new instance of the exception to be
thrown.
The Jar Spec says:
"Once the class loader finds a INDEX.LIST file in a particular jar file, it always trusts
the information listed in it. If a mapping is found for a particular class, but the class
loader fails to find it by following the link, an InvalidJarIndexException is thrown.
When this occurs, the application developer should rerun the jar tool on the
extension to get the right information into the index file."
InvalidJarIndexException is thrown when an index is corrupt. For example: a.jar
contains an index which has an entry for the package foo.bar in b.jar, but b.jar does
not contain foo/bar. The InvalidJarIndexException is a useful piece of information that
the deployment of the jar files is "bad". Arguably, this is really an Error. It indicates a
serious problem with the deployment that a reasonable application should not try to
handle.
Note: is it possible for class or resource loading to fail with other unchecked exceptions,
such as InternalError.
InvalidJarIndexException should be reviewed. Possibly: 1) either move it up to
java.util.jar as part of the Java SE Specification, or 2) alternatively drop it from the Jar
File Specification, or something else.
This appears to be a long standing spec issue from when support for Jar Indexing was
originally added.
[1] http://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#Overview