On Wed, 8 Jul 2026 13:50:38 GMT, Chen Liang <[email protected]> wrote:

>> src/java.base/share/classes/java/lang/runtime/ValueObjectMethods.java line 
>> 142:
>> 
>>> 140:                 long la = U.getLong(obj, offset);
>>> 141:                 result = 31 * result + (int) la;
>>> 142:                 result = 31 * result + (int) (la >>> 32);
>> 
>> This should probably use the behaviour of `Long::hashCode`:
>> Suggestion:
>> 
>>                 result = 31 * result + (int) (la ^ (la >>> 32));
>> 
>> or
>> Suggestion:
>> 
>>                 result = 31 * result + Long.hashCode(la);
>
> I don't think we are bound to use a particular behavior. The original 
> behavior does not introduce an inconsistency so I think it's fine to leave it 
> as-is. We might change these calculations if there are more compelling 
> reasons for subsequent previews, such as if another way to accumulate the 
> result is more hardware-friendly.

It would, to me, make most sense to align with Long.hashCode, unless there's a 
valid reason not to.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/31123#discussion_r3544942791

Reply via email to