JDK-6499851 : Unexpected MANIFEST behavior due to a trailing space character
  • Type: Bug
  • Component: tools
  • Sub-Component: jar
  • Affected Version: 6
  • Priority: P5
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-12-01
  • Updated: 2010-04-26
  • Resolved: 2006-12-01
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0-beta2"
Java(TM) SE Runtime Environment (build 1.6.0-beta2-b86)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b86, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
In one sentence, a trailing space character in the MANIFEST.MF file is treated by the parser as part of the option's value, which results in unexpected behavior.

I ran into this while test-driving the new Mustang's splash screen feature (which is pretty neat when it works). I exported the application in a jar, with the following manifest:
[code]

Manifest-Version: 1.0
Main-Class: ima.dialogs.main.MainFrame
SplashScreen-Image: icons/iMA_logo.gif
Class-Path: ../iText/itext-1.3.jar ../icons/jlfgr-1_0.jar
 
[/code]

As a result of a cut-and-paste operation, the third line, namely [code]
SplashScreen-Image: icons/iMA_logo.gif[/code]

, ended with a blank character. This caused the splash screen NOT to show. I spent a fair amount of time figuring out what's wrong - verifying that the referenced GIF is actually in the jar, trying to place GIF in the root of the jar, etc..., until I accidentally noticed this trailing blank.

I actually tried exporting a jar with and without this blank character and verified that it is indeed causing problems.

This started as a forum post:
http://forum.java.sun.com/thread.jspa?threadID=790708

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
As detailed above, add a blank (" ") at the end of line that starts with SplashScreen-Image in the manifest file. I did not experiment with other MANIFEST options and other Java releases.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would not expect trailing blanks to affect anything. It's just weird.
ACTUAL -
With the trailing blank in place, the splash screen is not shown then the exported jar is executed, e.g. java -jar testApp.jar

REPRODUCIBILITY :
This bug can be reproduced always.

Comments
EVALUATION The jar spec here http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#Name-Value%20pairs%20and%20Sections describes the format of the headers: header: name : value name: alphanum *headerchar value: SPACE *otherchar newline *continuation otherchar: any UTF-8 character except NUL, CR and LF So the space is, for better or worse, part of the name in the header. This may be unfortunate, but is part of the Jar spec and for compatibility reasons cannot be changed: it's all too possible that existing code by now depends on it.
01-12-2006