RFR: 8376294: ZipFile.Source.Key should not hold on to its BasicFileAttributes instance
Alan Bateman
alanb at openjdk.org
Mon Jan 26 14:01:31 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`.
I think this should be okay, and low risk.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/29411#issuecomment-3799756024
More information about the core-libs-dev
mailing list