You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Typically the values produced by identityHashCode and the default implementation of Object#hashCode are distinct.
Sometimes developers unintentionally assume they are unique. For instance, sometimes they use object.hashCode() as unique keys in maps.
I suggest adding an option that would force OpenJ9 to produce the same value for all the default hashCode values. It would make it easier to surface bugs when developers unintentionally assumed the hashcodes are distinct.
Java language specification allows identityHashCode to produce duplicate results, so there's no harm in that regard.
I do not suggest such a mode to be used in production as it might slow down the runtime.
Hotspot JIT has such "force all default hashcodes to be the same" for a long time with -XX:+UnlockExperimentalVMOptions -XX:hashCode=2.
Sample issues that would be hard to reproduce without "force the same identityHashCode":