Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4696354

jar umf puts Manifest file at end of jar

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.4.0
    • tools
    • jar
    • x86
    • windows_2000



      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)
      ======================================================================

            sherman Xueming Shen
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: