RFR: 8376294: ZipFile.Source.Key should not hold on to its BasicFileAttributes instance

Eirik Bjørsnøs eirbjo at openjdk.org
Mon Jan 26 10:43:41 UTC 2026


Please review this small enhancement which makes `ZipFile.Source.Key` capture the relevant `BasicFileAttributes` fields in its constructor instead of calling into `BasicFileAttributes` for each `hashCode` or `equals` invocation.

This reduces the memory footprint of `Key` instances. It should be performance positive since we avoid creating `FileTime` instances once per comparison and avoid synchronization getting the file key. 

Capturing fields early also improves readability by making it more obvious what this Key class is comparing.

Pure refactoring, no tests updated, `noreg-trivial`.

-------------

Commit messages:
 - Update copyright year
 - Capture relevant BasicFileAttributes fields in the Key constructor

Changes: https://git.openjdk.org/jdk/pull/29411/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29411&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8376294
  Stats: 15 lines in 1 file changed: 5 ins; 2 del; 8 mod
  Patch: https://git.openjdk.org/jdk/pull/29411.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/29411/head:pull/29411

PR: https://git.openjdk.org/jdk/pull/29411


More information about the core-libs-dev mailing list