Summary
-------
The JarFile API needs additional methods to allow libraries and tools deal with Multi-Release JAR files.
Problem
-------
The functionality provided by private class/methods showed below is really needed for developer to have straightforward and convenient access to the versioned entries and their real entry path name. It is desired to promote these to public APIs in JDK 10 to complete the JarFile multi-release support .
(1) jdk.internal.util.jar.VersionedStream.stream(JarFile)
(2) java.util.jar.JarFile.getRealName(JarEntry)
Solution
--------
To add two public methods as
JavaFile.versionedStream()
JarEntry.getRealname()'
Specification
-------------
http://cr.openjdk.java.net/~sherman/8189611/webrev [attached]
[java.util.jar.JarEntry.java]
...
+ /**
+ * Returns the real name of this {@code JarEntry}.
+ *
+ * If this {@code JarEntry} is an entry of a
+ * <a href="JarFile.html#multirelease">multi-release jar file</a> and the
+ * {@code JarFile} is configured to be processed as such, the name returned
+ * by this method is the path name of the versioned entry that the
+ * {@code JarEntry} represents, rather than the path name of the base entry
+ * that {@link getName()} returns. If the {@code JarEntry} does not represent
+ * a versioned entry of a multi-release {@code JarFile} or the {@code JarFile}
+ * is not configured for processing a multi-release jar file, this method
+ * returns the same name that {@link #getName()} returns.
+ *
+ * @return the real name of the JarEntry
+ *
+ * @since 10
+ */
+ public String getRealName()
...
[java.util.jar.JarFile.java]
...
+ /**
+ * Returns a {@code Stream} of the versioned jar file entries.
+ *
+ * <p>If this {@code JarFile} is a multi-release jar file and is configured to
+ * be processed as such, then an entry in the stream is the latest versioned entry
+ * associated with the corresponding base entry name. The maximum version of the
+ * latest versioned entry is the version returned by {@link getVersion()}.
+ * The returned stream may include an entry that only exists as a versioned entry.
+ *
+ * If the jar file is not a multi-release jar file or the {@code JarFile} is not
+ * configured for processing a multi-release jar file, this method returns the
+ * same stream that {@link stream()} returns.
+ *
+ * @return stream of versioned entries
+ * @since 10
+ */
+ public Stream<JarEntry> versionedStream()
+
...