JDK-4338238 : JarInputStream returns null Manifest for Indexed JarFile
  • Type: Bug
  • Component: tools
  • Sub-Component: jar
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Won't Fix
  • OS: generic,solaris_8
  • CPU: generic,sparc
  • Submitted: 2000-05-15
  • Updated: 2020-06-11
  • Resolved: 2020-06-11
Related Reports
Relates :  
Relates :  
Description
Method getManifest in java.util.jar.JarInputStream returns null Manifest for a Indexed JarFile . While it is returning exact values for an unindexed Jarfile .

This occurs in Win32 platforms (95,98,NT) and Solaris 2.7 

Steps to reproduce the bug
---------------------------
1) set the path to latest merlin build
2) copy the attached files 
3) javac GetManifestTests.java
4) java GetManifestTests


Name: jl125535			Date: 11/11/2002


EXTRA RELEVANT SYSTEM CONFIGURATION :
Construct one jar file that contains manifest file so that
manifest file is not first entry in jar file.(Use for
example zip tool)



A DESCRIPTION OF THE PROBLEM :
Even the jar file contains manifest file, the getManifest
method returns null

Jar tool provided by Sun will always generate such jar file
that manifest is first entry.
But specification of jar file does not say that manifest
must be the first entry.
http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. create jar file that contains manifest file, so that
mnaifest is not first entry in jar file(use for example zip
tool)
2. run example code(Test <jarfile name>)

EXPECTED VERSUS ACTUAL BEHAVIOR :
Test program prints out:
Manifest is:null

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.util.jar.JarInputStream;
import java.util.jar.Manifest;
import java.io.FileInputStream;

public class Test
{
    public static void main(String arg[])
    {
        try
        {
            FileInputStream fin = new FileInputStream(arg[0]);

            JarInputStream jin = new JarInputStream(fin);

            Manifest m = jin.getManifest();
            System.out.println("Manifest is:" + m);
        }
        catch(Exception e )
        {
        }
    }
}
---------- END SOURCE ----------
(Review ID: 166718)
======================================================================

Comments
EVALUATION The java.util.jar.JarInputStream constructor locates the Manifest entry within the list of Jar entries by assuming that it is the 2nd entry (past the initial directory entry for META-INF/"). This assumption doesn't hold for an indexed jar file. The implementation is oblivious to the possibility of a jar index file META-INF/INDEX.LIST appearing prior to the entry for the actual Manifest entry. ###@###.### 2002-09-27
27-09-2002