JDK-4333854 : jar skip's last line of manifest file
  • Type: Bug
  • Component: tools
  • Sub-Component: jar
  • Affected Version: 1.2.2,1.3.0,1.3.1,1.4.2,6,6u2
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_nt,windows_2000,windows_xp
  • CPU: x86
  • Submitted: 2000-04-27
  • Updated: 2007-02-05
  • Resolved: 2002-04-27
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Description

Name: skT45625			Date: 04/27/2000


java version "1.2.2"
Classic VM (build JDK-1.2.2-004, native threads, symcjit)


The jar tool on windows platform (verified on Win98 and Win2000)
would skip the last line of manifest.  Example:  If the manifest
has exactly the two following lines:

Name: test/Test.class
Java-bean: True

then the following command
    jar cfm test.jar manifest.txt test/*.class
will produce a jar file that can't be used as a Java Bean.
If you open the jar and extract MANIFEST.MF, you will see that
the last line in the original manifest file is missing.

Additional Information provided upon request;
---------------------------------
readme.txt:
1.  Save all files in a folder "manifestbug", and cd into the 
       Hello.java
       manifest1.txt
       manifest2.txt
       run.bat
       readme.txt

2.  The only difference between "manifest1.txt" and "manifest2.txt" is the
    extra blank line in "manifest2.txt".  Double-click both files in Windows
    Explorer should launch the files in a note pads.  Move cursor to the end
    of the last line to verify the difference.

3.  Run the batch file at the command line as follows:
       run 1
    This will create "manifestbug.jar" using "manifest1.txt" at the parent directory.
    
4.  Start BDK1.1 and load the new jar, you will see the following error:
      Jar file C:\BDK1.1\jars\manifestbug.jar didn't have any beans!
      Each jar file needs to contain a manifest file describing which entries are
      beans.  You can should provide a suitable manifest when you create the jar.

5.  Now repeat step 3 with the command
       run 2
    This will create "manifestbug.jar" using "manifest2.txt" at the parent directory.

6.  Start BDK1.1 and load the new jar, it will work!

=========
Use jar or winzip to extract the MANIFEST.INF inside "manifestbug.jar", you will
see why the first jar can't be used as a Java bean.

Hello.java:
---------
package manifestbug;
import java.awt.*;

public class Hello extends Canvas {
  public Hello() {
    setSize(60,30);
  }

  public void paint(Graphics g){
    g.drawString( "Hello", 10, 20 );
  }
}

manifest1.txt:
----------
Name: manifestbug/Hello.class
Java-Bean: True


manifest2.txt:
-----------
Name: manifestbug/Hello.class
Java-Bean: True

run.bat:
-----
@echo Creating manifestbug.jar with manifest%1.txt
del *.class
cd ..
javac manifestbug\Hello.java
jar cfm manifestbug.jar manifestbug\manifest%1.txt manifestbug\*.class
cd manifestbug

(Review ID: 103379) 
======================================================================

Comments
EVALUATION Not a bug. Linefeed at the end of a manifest line is a part of the manifest spec.
11-06-2004

WORK AROUND Name: skT45625 Date: 04/27/2000 Include explicit linefeed at the end of last line in manifest file. Comment: if "manifest" file is to be human readable and friendly, the jar tool should allow more flexible text style (some people and text-editor don't automatically insert extra linefeed at the end of the last line). ======================================================================
11-06-2004

PUBLIC COMMENTS Not a bug. Linefeed at the end of a manifest line is a part of the manifest spec.
10-06-2004