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

javac throws error "Invalid CEN header (invalid zip64 extra data field size)" after JDK-8314891

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • tbd
    • 26
    • core-libs
    • 22
    • generic
    • generic

      With JDK-8314891, additional Zip64 extra header validation is added to both ZipFile.java and ZipFileSystem.java, ZipFile.java is used by class loader to load and read jar files.

      The change breaks javac when there is old jar which can't pass the validation. We could set system property like -Djdk.util.zip.disableZip64ExtraFieldValidation=true to disable the validation in ZipFile.java, but javac actually use both ZipFile and ZipFileSystem, so even with `-Djdk.util.zip.disableZip64ExtraFieldValidation=true` javac still fails at Zip64 extra header validation.

      Here is the steps to reproduce the bug:
      1. Download aspectjweaver-1.8.13.jar from maven repo: https://repo1.maven.org/maven2/org/aspectj/aspectjweaver/1.8.13/aspectjweaver-1.8.13.jar

      2.1. With any JDK22+ version, run `javac -cp ~/aspectjweaver-1.8.13.jar ~/HelloWorld.java`, it fails with error "error: error reading /home/xlpeng/aspectjweaver.jar; Invalid CEN header (invalid zip64 extra data field size)", it is caused by the validation in ZipFile.java.

      2.2. Run command `export JAVA_TOOL_OPTIONS="-Djdk.util.zip.disableZip64ExtraFieldValidation=true"; javac -cp ~/aspectjweaver-1.8.13.jar ~/HelloWorld.java`, it will fail with error like:
      ```
      Picked up JAVA_TOOL_OPTIONS: -Djdk.util.zip.disableZip64ExtraFieldValidation=true
      /home/xlpeng/HelloWorld.java:1: error: cannot access unnamed package
      public class HelloWorld {
      ^
        ZipException opening "aspectjweaver.jar": Invalid CEN header (invalid zip64 extra data field size)
      1 error
      printing javac parameters to: /tmp/javac.20250724_005954.args

      ```, this time the error is from ZipFileSystem.


      I also ran `zipdetails` to find out the Zip64 Extended Information form the jar file which didn't pass the validation.

      ```
      036C93 LOCAL HEADER #9B 04034B50
      036C97 Extract Zip Spec 0A '1.0'
      036C98 Extract OS 00 'MS-DOS'
      036C99 General Purpose Flag 0800
             [Bits 1-2] 0 'Normal Compression'
             [Bit 11] 1 'Language Encoding'
      036C9B Compression Method 0008 'Deflated'
      036C9D Last Mod Time 4B546AF9 'Fri Oct 20 13:23:50 2017'
      036CA1 CRC CDE16ADA
      036CA5 Compressed Length 00002731
      036CA9 Uncompressed Length 00005B3C
      036CAD Filename Length 0027
      036CAF Extra Length 0014
      036CB1 Filename 'org/aspectj/apache/bcel/Constants.class
                                   '
      036CD8 Extra ID #0001 0001 'ZIP64'
      036CDA Length 0010
      036CDC PAYLOAD


      Unexpecded END at offset 0003940D, value 46BF423C
      Done

      ```

            lancea Lance Andersen
            xpeng Xiaolong Peng
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: