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

Jaikiran Pai jpai at openjdk.org
Mon Jan 26 16:34:15 UTC 2026


On Mon, 26 Jan 2026 10:23:16 GMT, Eirik Bjørsnøs <eirbjo at openjdk.org> wrote:

> Please review this small enhancement which makes `ZipFile.Source.Key` capture the relevant `BasicFileAttributes` fields eagerly 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 obvious from the field declarations what information Key uses when comparing equality.
> 
> Pure refactoring, no tests updated, `noreg-trivial`.

This looks OK to me.

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

Marked as reviewed by jpai (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/29411#pullrequestreview-3706893286


More information about the core-libs-dev mailing list