Skip to content

8186464: ZipFile cannot read some InfoZip ZIP64 zip files#835

Draft
fitzsim wants to merge 1 commit into
openjdk:masterfrom
fitzsim:backport-8186464-zip64
Draft

8186464: ZipFile cannot read some InfoZip ZIP64 zip files#835
fitzsim wants to merge 1 commit into
openjdk:masterfrom
fitzsim:backport-8186464-zip64

Conversation

@fitzsim

@fitzsim fitzsim commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

This is a third attempt at #452, hopefully this time with clearer background and context.

Background

In the OpenJDK 9 timeframe, the java.util.zip.ZipFile was rewritten to be pure Java, by:

JDK-8145260 To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk

This rewrite was never backported to OpenJDK 8 and would be too invasive and risky to backport in its entirety now.

This means that OpenJDK 8's java.util.zip.ZipFile implementation is backed by JNI C code, implemented in jdk8u/jdk/src/share/native/java/util/zip/zip_util.c (core algorithms) and jdk8u/jdk/src/share/native/java/util/zip/ZipFile.c (JNI wrapper C code).

ZipFile.c was deleted during development of OpenJDK 9, in the JDK-8145260 commit:

openjdk/jdk9u@2b91819

OpenJDK 8 also contains Zip algorithms in a pure Java demo library, under jdk8u/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs, added during development of OpenJDK 7, by:

JDK-6990846 Demo: NIO.2 filesystem provider for zip/jar archives

During development of OpenJDK 9, this pure Java code was promoted from being a demo package to being a fully-supported package, by:

JDK-8038500: (zipfs) Upgrade ZIP provider to be a supported provider

It remains demo-only in OpenJDK 8, and there are no plans to backport the promotion change to OpenJDK 8.

Desired Java-to-C Backport

We would like to backport JDK-8186464: ZipFile cannot read some InfoZip ZIP64 zip files that was fixed during the development of OpenJDK 10.

OpenJDK 8 users have run into this issue in real-world applications.

However, the original JDK-8186464 fix was made against the pure Java ZipFile.java implementation.

The same logic of the pure Java JDK-8186464 fixes applies readily to the core C algorithms in zip_util.c. Andrew has converted the Java code in the original fix to C code applied to zip_util.c.

In our Red Hat RPMs, since 2020, we have been shipping and maintaining this patch.

This Red Hat internal backport patch, in addition to fixing the C code, also updates the demo pure Java code which was affected by the same issue reported in JDK-8186464.

However, this Java part of the patch is somewhat incidental, since, as established in the background section, the production/important Zip algorithms in OpenJDK 8 are the C implementations thereof.

Changes

These changes have been deployed to Red Hat customers since 2020, with minor updates from time-to-time as required to keep the patch applicable.

I applied the patch, maintained by Andrew Hughes, as-is from:

https://gitlab.com/redhat/centos-stream/rpms/java-1.8.0-openjdk/-/raw/openjdk-portable-centos-9/jdk8186464-rh1433262-zip64_failure.patch?ref_type=72646f68c8ccb1bdbee3d2249abccf90980eb7d6

Testing

I confirmed that the changes to ReadZip.java exercise the new code zip_utils.c code and produce correct results.

CI runs showed no regressions.

Newer OpenJDK versions and zip_util.c

zip_util.c still survives in newer versions up to and including tip (i.e., OpenJDK 27).

It is used to load Zip files from the bootstrap classpath (-Xbootclasspath), which happens during JVM bring-up, prior to Java features (such as the pure Java ZipFile implementation) being available.

Conceivably newer versions of zip_util.c could be patched in the same was as proposed here, however no one has ever needed to load InfoZip ZIP64 zip files on the bootstrap classpath.

There was not much interest when I proposed this in:

JDK-8334048: -Xbootclasspath can not read some ZIP64 zip files
openjdk/jdk#19678

(This could have subsequently become a true backport to OpenJDK 8 zip_util.c.)

In summary, given that no one needs this code in zip_util.c in new OpenJDK versions due to zip_util.c only being used in very specific circumstances, and given its importance in OpenJDK 8 as backing the sole production Zip API, I think it makes more sense just to patch zip_util.c only in OpenJDK 8 directly as we're proposing in this pull request.



Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • JDK-8186464 needs maintainer approval

Issue

  • JDK-8186464: ZipFile cannot read some InfoZip ZIP64 zip files (Bug - P3)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk8u-dev.git pull/835/head:pull/835
$ git checkout pull/835

Update a local copy of the PR:
$ git checkout pull/835
$ git pull https://git.openjdk.org/jdk8u-dev.git pull/835/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 835

View PR using the GUI difftool:
$ git pr show -t 835

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk8u-dev/pull/835.diff

Co-authored-by: Andrew John Hughes <andrew@openjdk.org>
Backport-of: 02b9452ed39eccdfe3210e65b17d4759333c0f15
@bridgekeeper

bridgekeeper Bot commented Jun 27, 2026

Copy link
Copy Markdown

👋 Welcome back fitzsim! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk

openjdk Bot commented Jun 27, 2026

Copy link
Copy Markdown

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk Bot changed the title Backport 02b9452ed39eccdfe3210e65b17d4759333c0f15 8186464: ZipFile cannot read some InfoZip ZIP64 zip files Jun 27, 2026
@openjdk

openjdk Bot commented Jun 27, 2026

Copy link
Copy Markdown

This backport pull request has now been updated with issue from the original commit.

@openjdk openjdk Bot added the backport Port of a pull request already in a different code base label Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Port of a pull request already in a different code base

Development

Successfully merging this pull request may close these issues.

1 participant