JDK-6594305 : Incorrect Manifest file parsing in JDK
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Affected Version: 6u2
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2007-08-17
  • Updated: 2010-04-06
  • Resolved: 2007-11-08
Related Reports
Duplicate :  
Description
OPERATING SYSTEM(S):
Windows XP

FULL JDK VERSION(S):
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b04)
Java HotSpot(TM) Client VM (build 1.6.0_01-b04, mixed mode)

DESCRIPTION:

On executing the below Test case (ManifestTest.java) using the manifest file MANIFEST.MF we could see the following output

[Eclipse-AutoStart, Manifest-Version, Bundle-Localization, Bundle-Name, Copyright, Require-Bundle, DynamicImport-Package, Bundle-Vendor, Bundle-Version, SCCSID, Bundle-Activator, Bundle-ManifestVersion, J2EE-DeploymentFactory-Implementation-Class, Import-Package, Bundle-SymbolicName, Eclipse-RegisterBuddy]

The issue found here is that the "Export-Package" attribute, which is present in the manifest file, does not appear in the above list.


Testcase:
---------

import java.io.*;
import java.util.jar.*;
public class ManifestTest {
    public static void main(String args[])
    {
        try {
            FileInputStream fis = new FileInputStream(args[0]); 
            Manifest mf = new Manifest(fis); 
            System.out.println(mf.getMainAttributes().keySet());
        } catch (Exception e) {
        }
    }
}

Steps to reproduce:

Compile and run ManifestTest.java:

  java ManifestTest [manifest file]

The manifest file we used to reproduce the problem can be downloaded from here:

  ftp://ftp.emea.ibm.com/fromibm/other/MANIFEST.MF


Analysis:

In Attributes.java ,there is function called

  read(Manifest.FastInputStream is, byte[] lbuf)

which parses the attribute-value pair and puts in the table.The issue is when it continues to parse and reaches the last line of the last attribute.It collects the last line but it happens to go into the condition

  if (is.peek() == ' ') {}

and then continue with the loop. As there are no more lines to read, it exits the loop, and the last attribute is not captured.

So the fix could be like

  if (is.peek() == ' ' && is.available()!=0) {}

which would check for the availability and based on that it may enter the "if" or not.

Comments
EVALUATION The MANIFEST.MF needs a newline at the end of the file.
08-11-2007

EVALUATION MANIFEST.zip uploaded to the bug as attachment. Please proceed with evaluation.
01-10-2007

EVALUATION Please provide the MANIFEST.MF file: it is not available from the location (ftp://ftp.emea.ibm.com/fromibm/other/MANIFEST.MF) indicated in the Description.
23-08-2007