On Mon, 9 Feb 2026 12:27:31 GMT, Eirik Bjørsnøs <[email protected]> wrote:
> Please review this PR introducing a test to verify that `ZipFile::size` > reports the actual number of CEN entries in a ZIP file, despite an incorrect > number being reported in the END header. > > Background: > > The `ZipFile` implementation treats `ENDTOT` as an indication, but falls back > to counting CEN entries if this number is too low. After parsing the CEN, > there is also code to adjust the total down to the actual count of CEN > entries. > > The behavior of always reporting the actual number of CEN entries has no > current test coverage in the JDK. It seems good to have tests excercising > these code paths and protecting against regressions in this area. > > Verification: > > Verified that the new test catches introduced regressions in handling over- > and underreported numbers in ENDTOT and that no existing test catches such > regressions. > > Test-only change, `noreg-self`. Thanks for Tackling this Eirik. A couple minor comments below. A follow one would be to also check: 4.3.15 Zip64 end of central directory locator but can be a follow on project test/jdk/java/util/zip/ZipFile/IncorrectEndTot.java line 2: > 1: /* > 2: * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights > reserved. I believe this is a new Test so 2026 is what we need for the copyright test/jdk/java/util/zip/ZipFile/IncorrectEndTot.java line 60: > 58: Arguments.of(10, 11), // CEN has one less than ENDTOT > 59: Arguments.of(11, 10), // CEN has one more than ENDTOT > 60: Arguments.of(0, 10) // No CEN entries (empty ZIP) Should you include Arguments.of(0, 0) to test an empty ZIP? ------------- PR Review: https://git.openjdk.org/jdk/pull/29635#pullrequestreview-3774857487 PR Review Comment: https://git.openjdk.org/jdk/pull/29635#discussion_r2784113108 PR Review Comment: https://git.openjdk.org/jdk/pull/29635#discussion_r2784427229
