JDK-8157524 : Revert JarFile methods "entries" and "stream" to Java 8 behavior
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-05-23
  • Updated: 2016-07-28
  • Resolved: 2016-07-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b129Fixed
Related Reports
Relates :  
Relates :  
Description
Before JarFile was enhanced to support multi-release jars, the entries and stream methods would create an Enumeration or a Stream over all of the entries in the JarFile.  After adding support for multi-release jars, if the JarFile was constructed with versioning enabled (e.g. with parameter Release.RUNTIME), the Enumeration or Stream only returned a view of the versioned entries.

This new behavior needs to be reverted back to the way it was, iterating over all the entries.  New methods need to be created to provide a versioned view of of the entries, perhaps named versionedEntries and versionedStream.

This change needs to be coordinated with changing the jar scanning mechanism of the module system.

This change should fix, or make moot the issues identified in JDK-8156999 and JDK-8150678.

Comments
New versionedStream and versionedEntries methods do not need to be created. They can be easily constructed as follows: Stream<JarEntry> versionedStream(JarFile jf) { return jf.stream().map(JarEntry::getName) .filter(name -> !name.startsWith("META-INF/versions/")) .map(jf::getJarEntry); } Enumeration<JarEntry> versionedEntries(JarFile jf) { Iterator<JarEntry> it = versionedStream(jf).iterator(); return new Enumeration<JarEntry>() { @Override public boolean hasMoreElements() { return it.hasNext(); } @Override public JarEntry nextElement() { return it.next(); } }; }
15-07-2016