JDK-4620323 : Manifest read() should remove 512 byte limit for Manifest main attributes
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2002-01-08
  • Updated: 2003-08-07
  • Resolved: 2003-08-07
Related Reports
Duplicate :  
Description
Manifest read() should remove 512 byte limit for Manifest main attributes

Comments
EVALUATION Agreed. Looks like it should be relatively easy to fix. We should replace the fixed length buffer in Manifest.java: // Line buffer byte[] lbuf = new byte[512]; with an unbounded length data structure. ###@###.### 2003-06-19 The Jar File Specification makes it clear that lines in the Manifest file must be a maximum of 72 bytes long, with provision for line continuation. Java APIs like Manifest.write correctly generate such line continuations. Keeping this in mind, there is no reason why the implementation need accept any input lines longer than 72 bytes. The fact that it accepts even 512 bytes is generous. There is no bug in the current implementation. I have re-classified this bug as RFE. However, the specification is poor. This kind of restriction (RFC822) was intended as an interchange file format for ancient computer systems. Today we should design all file formats to never have such arbitrary length restrictions. Because the jar file format is an interchange format between different Java implementations, the old format must be supported for years, if not decades. The default must remain to generate Manifest files with the 72byte limit, and the limit must continue to be documented, so that tools that generate Manifests programmatically can continue to generate portable jar files. Nevertheless, the spec should be changed so that all future implementations have no line length limit. Perhaps 20 years after this is implemented, we can abandon compatibility with old Java implemenations and by default generate new jar files with long lines. ###@###.### 2003-08-07
07-08-2003

WORK AROUND Use the Manifest.write method to generate manifest files instead of writing them "by hand". For example, this code: public static void main (String[] args) throws Exception { Manifest m = new Manifest(); Attributes a = m.getMainAttributes(); a.put(Attributes.Name.MANIFEST_VERSION, "3.14"); a.put(Attributes.Name.CLASS_PATH, "/some/very/long/paaaaaaaaaaaaaaaaaaaaaaaaaath1 " + "/some/very/long/paaaaaaaaaaaaaaaaaaaaaaaaaath2 " + "/some/very/long/paaaaaaaaaaaaaaaaaaaaaaaaaath3 " + "/some/very/long/paaaaaaaaaaaaaaaaaaaaaaaaaath4 " + "/some/very/long/paaaaaaaaaaaaaaaaaaaaaaaaaath5 " + "/some/very/long/paaaaaaaaaaaaaaaaaaaaaaaaaath6"); m.write(System.out); generates an output file with 72-byte lines and continuation lines. ###@###.### 2003-08-07
07-08-2003