JDK-8215788 : Clarify JarInputStream Manifest access
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Affected Version: 1.2.0,8,11,12
  • Priority: P5
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2018-12-19
  • Updated: 2022-10-06
  • Resolved: 2022-09-28
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 20
20 b18Fixed
Related Reports
CSR :  
Relates :  
Relates :  
Description
A DESCRIPTION OF THE PROBLEM :
If MANIFTEST.MF is not the first (or second) entry in a .jar-file, JarFileInputStream does not find the MANIFEST.MF.

It should be better documented (in JavaDoc-comment), that it checks only the first (two) entries so that the result of null of getManifest()-method does not explicit mean, that there is not any MANIFEST.MF.

As for a RFE the class could offer a convenience setting, that it checks for that on every call to getNextEntry() and when found, populate the internal Manifest-variable so that after all entries were scanned, getManifest()'s result really shows if there is or is not an MANIFEST.MF in the jar.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
create a .jar, where the MANIFEST.MF is not one of the first two entries (any normal Zip-Programm could do that)


FREQUENCY : always



Comments
Changeset: 9db95edd Author: Lance Andersen <lancea@openjdk.org> Date: 2022-09-28 19:22:19 +0000 URL: https://git.openjdk.org/jdk/commit/9db95edd0133cb31358416829c942f5dcb84fc55
28-09-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/10045 Date: 2022-08-26 15:48:55 +0000
13-09-2022

This is long standing behavior goes back to the original implementation in JDK 1.2 (1998). It has been looked at several times over the years. It might be that JarInputStream's doc should be updated to specify the long standing behavior.
21-12-2018

To reproduce the issue, run the attached test case provided by the submitter. JDK 8u191 - Fail JDK 11.0.1 - Fail JDK 12-ea+21 - Fail Output: after open: JarInputStream did NOT find META-INF/MANIFEST.MF META-INF/MANIFEST.MF is the 11. entry after last entry: JarInputStream did NOT find META-INF/MANIFEST.MF
21-12-2018