RFR: 8317678: Fix up hashCode() for ZipFile.Source.Key
Pavel Rappo
prappo at openjdk.org
Tue Oct 10 08:56:59 UTC 2023
On Tue, 10 Oct 2023 08:32:28 GMT, Sean Coffey <coffeys at openjdk.org> wrote:
> Fix up java.util.zip.ZipFile$Source hashCode() impl so that duplicate Source objects aren't created for the same zip file.
src/java.base/share/classes/java/util/zip/ZipFile.java line 1444:
> 1442: } else {
> 1443: return ((int)(t ^ (t >>> 32))) + file.hashCode();
> 1444: }
Consider this trivial simplification:
Suggestion:
Object fk = attrs.fileKey();
return Long.hashCode(t)
+ (fk != null ? fk.hashCode() : file.hashCode());
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16115#discussion_r1351918933
More information about the core-libs-dev
mailing list