[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-serviceability-dev
Subject:    Re: RFR: 8268764: Use Long.hashCode() instead of int-cast where applicable [v2]
From:       Kevin Walls <kevinw () openjdk ! java ! net>
Date:       2021-06-30 13:23:14
Message-ID: kQskR6msy1oj6QYFJZruPlVBkbchJQb7R-quaPk0r74=.4075ca4a-5724-4b7d-866e-e8895a9a721d () github ! com
[Download RAW message or body]

On Wed, 30 Jun 2021 11:49:51 GMT, Сергей Цыпанов \
<github.com+10835776+stsypanov@openjdk.org> wrote:

> > In some JDK classes there's still the following hashCode() implementation:
> > 
> > long objNum;
> > 
> > public int hashCode() {
> > return (int) objNum;
> > }
> > 
> > This outdated expression should be replaced with Long.hashCode(long) as it
> > 
> > - uses all bits of the original value, does not discard any information upfront. \
> > For example, depending on how you are generating the IDs, the upper bits could \
> > change more frequently (or the opposite). 
> > - does not introduce any bias towards values with more ones (zeros), as it would \
> > be the case if the two halves were combined with an OR (AND) operation. 
> > See https://stackoverflow.com/a/4045083
> > 
> > This is related to https://github.com/openjdk/jdk/pull/4309
> 
> Сергей Цыпанов has updated the pull request with a new target base due \
> to a merge or a rebase. The incremental webrev excludes the unrelated changes \
> brought in by the merge/rebase. The pull request contains two additional commits \
> since the last revision: 
> - Merge branch 'master' into 8268764
> - 8268764: Use Long.hashCode() instead of int-cast where applicable

The changes look good to me, we have done the same thing elsewhere.  This changes \
things in different functional areas, which is maybe unusual, but seems fine for a \
small change as long as nobody objects.

Some of the files also need a (C) year update.

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

PR: https://git.openjdk.java.net/jdk/pull/4491


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic