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

jar should not compress the manifest directory entry

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 20
    • None
    • tools
    • None
    • jar
    • b27

      The jar tool uses compression for the directory entry for META-INF/, resulting in a an entry with a compressed size of two bytes. It does not compress other directories.

      This seems to be discouraged by the jar spec, APPNOTE 4.3.8 says "Zero-byte files, directories, and other file types that contain no content MUST NOT include file data."

      This was discovered because this (not yet released) change to go's zipreader implementation causes it to reject the archives created by jar: https://github.com/golang/go/issues/54801. The go change may be reverted to preserve the current lenient behaviour and allow it to continue reading jar files with this issue, but I think it's still worth fixing the jar tool.

      See the following example, where the directory entry for a/ from the input is uncompressed, but the entry for META-INF/ is compressed.

      ```
      $ mkdir a/
      $ echo hello > a/test.txt
      $ jar cf j.jar a/
      $ unzip -lv j.jar
      Archive: j.jar
       Length Method Size Cmpr Date Time CRC-32 Name
      -------- ------ ------- ---- ---------- ----- -------- ----
             0 Defl:N 2 0% 2022-11-30 10:37 00000000 META-INF/
            60 Defl:N 59 2% 2022-11-30 10:37 af937e93 META-INF/MANIFEST.MF
             0 Stored 0 0% 2022-11-30 10:37 00000000 a/
             6 Defl:N 8 -33% 2022-11-30 10:37 363a3020 a/test.txt
      -------- ------- --- -------
            66 69 -5% 4 files
      ```

            cushon Liam Miller-Cushon
            cushon Liam Miller-Cushon
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: