RFR: 8290041: ModuleDescriptor.hashCode is inconsistent

Peter Levart plevart at openjdk.org
Wed Aug 10 06:56:39 UTC 2022


On Sun, 7 Aug 2022 08:14:58 GMT, Alan Bateman <alanb at openjdk.org> wrote:

> > Sorry for joining late. I noticed that modsHashCode is a private method and it takes Iterable as a parameter. But everywhere it is called, a Set is passed to it. So why not just calling the set.hashCode() and be done with it? It may be even more optimal in some cases.
> 
> There's a lot going on here as the hash code is generated at link time and we also want it to be reproducible across builds. We also had a CDS bug with the the way that Enum objects were archived - Ioi has fixed that in JDK 19 so we have one less thing to be concerned about now.

Ah, I see. Enum.hashCode() is identity hash code. I have been beaten by that in the past and apparently this is a sore point for many. I wonder if it could be changed. Is unstable hashCode (accross JVM instances) a feature here or just unfortunate implementation detail?

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

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


More information about the core-libs-dev mailing list