JarFile (Java SE 10 & JDK 10 )
The JarFile class is used to read the contents of a jar file
from any file that can be opened with java.io.RandomAccessFile.
It extends the class java.util.zip.ZipFile with support
for reading an optional Manifest entry, and support for
processing multi-release jar files. The Manifest can be used
to specify meta-information about the jar file and its entries.
A multi-release jar file is a jar file that
contains a manifest with a main attribute named "Multi-Release",
a set of "base" entries, some of which are public classes with public
or protected methods that comprise the public interface of the jar file,
and a set of "versioned" entries contained in subdirectories of the
"META-INF/versions" directory. The versioned entries are partitioned by the
major version of the Java platform. A versioned entry, with a version
n, 8 < n, in the "META-INF/versions/{n}" directory overrides
the base entry as well as any entry with a version number i where
8 < i < n.
By default, a JarFile for a multi-release jar file is configured
to process the multi-release jar file as if it were a plain (unversioned) jar
file, and as such an entry name is associated with at most one base entry.
The JarFile may be configured to process a multi-release jar file by
creating the JarFile with the
JarFile(File, boolean, int, Runtime.Version) constructor. The
Runtime.Version object sets a maximum version used when searching for
versioned entries. When so configured, an entry name
can correspond with at most one base entry and zero or more versioned
entries. A search is required to associate the entry name with the latest
versioned entry whose version is less than or equal to the maximum version
(see getEntry(String)).
Class loaders that utilize JarFile to load classes from the
contents of JarFile entries should construct the JarFile
by invoking the JarFile(File, boolean, int, Runtime.Version)
constructor with the value Runtime.version() assigned to the last
argument. This assures that classes compatible with the major
version of the running JVM are loaded from multi-release jar files.
If the verify flag is on when opening a signed jar file, the content of
the file is verified against its signature embedded inside the file. Please
note that the verification process does not include validating the signer's
certificate. A caller should inspect the return value of
JarEntry.getCodeSigners() to further determine if the signature
can be trusted.
Unless otherwise noted, passing a null argument to a constructor
or method in this class will cause a NullPointerException to be
thrown.