United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4696354 : jar umf puts Manifest file at end of jar

Details
Type:
Bug
Submit Date:
2002-06-03
Status:
Open
Updated Date:
2010-10-26
Project Name:
JDK
Resolved Date:
Component:
tools
OS:
windows_2000
Sub-Component:
jar
CPU:
x86
Priority:
P4
Resolution:
Unresolved
Affected Versions:
1.4.0
Targeted Versions:

Related Reports
Relates:
Relates:

Sub Tasks

Description

Name: nt126004			Date: 06/03/2002


FULL PRODUCT VERSION :
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)

also

java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

Windows 2000



A DESCRIPTION OF THE PROBLEM :
If you produce JAR using these two steps:

1. Create JAR from some files without adding manifest
2. Update JAR to include manifest

If you use following code on jar-file produced this way
getManifest() fails.

File jarFile = new File("filename.jar");
inputStream = new FileInputStream(jarFile);
jarInputStream = new JarInputStream(inputStream);
Manifest manifest = jarInputStream.getManifest();

Reason seems to be that manifest is not the first file in
the jar-file. There is allready a bug report (4263225)
about this issue,it was marked "will not be fixed" state.

  Bug report states that "Secondly, the manifest file should
always be the first entry in a particular jar file, in fact
our jar tool enforces this restriction. Of course, we
cannot prevent other vendors from manually putting the
manifest at any other place in a jar, which is otherwise
semantically equivalent.". As demonstrated incompabtible
jar-file can be created also by using Sun's jar-tool.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create JAR from some files without adding manifest
2. Update JAR to include manifest

If you use following code on jar-file produced this way
getManifest() fails.

EXPECTED VERSUS ACTUAL BEHAVIOR :
getManifest should not fail.

-------------------- BEGIN SOURCE -----------------------
//compile.bat
javac.exe *.java


// pack.bat
jar cvfM JarTest.jar *.java *.class
jar umf Manifest.mf JarTest.jar


// run.bat
java.exe -classpath JarTest.jar JarTest

// Manifest.mf

// JarTest.java
import java.util.jar.*;
import java.io.*;
public class JarTest {
    public static void main(String[] args) {
        try {
            File jarFile = new File("filename.jar");
            InputStream inputStream = new FileInputStream(jarFile);
            JarInputStream jarInputStream = new JarInputStream(inputStream);
            Manifest manifest = jarInputStream.getManifest();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

--------------------- END SOURCE ------------------------

This bug can be reproduced always.
(Review ID: 146951) 
======================================================================

                                    

Comments



Hardware and Software, Engineered to Work Together