[15] RFR (xs) 8046362 IdentityHashMap.hash comments should be clarified

Martin Buchholz martinrb at google.com
Mon Feb 10 15:52:13 UTC 2020


On Fri, Feb 7, 2020 at 2:47 PM David Holmes <david.holmes at oracle.com> wrote:

> Hi Martin,
>
> On 8/02/2020 3:10 am, Martin Buchholz wrote:
> > I explored System.identityHashCode (see below).
>
> System.identityHashCode is a VM call that is potentially very expensive.
> In the worst-case it triggers monitor inflation.
>

I can believe that.  The VM can't simply return the address of an object
because ... the object might move and an address is a poor hash code
because low bits will tend to be zero.

But  IdentityHashMap already calls System.identityHashCode - that price
must be paid.

My proposal is still "Let's trust System.identityHashCode to produce
acceptable hash codes"


More information about the core-libs-dev mailing list