RFR: 8352171: Arrays.hashCode for sub-range of byte array API addition [v2]
Chen Liang
liach at openjdk.org
Mon Feb 9 21:36:06 UTC 2026
On Sat, 29 Mar 2025 07:51:27 GMT, Zihao Lin <zlin at openjdk.org> wrote:
>> Add the java.util.Arrays.hashCode(byte[], int start, int end).
>>
>> Hi team, I am new here, please give me some guidance. Thank you.
>
> Zihao Lin 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 'openjdk:master' into dev
> - 8352171: Arrays.hashCode for sub-range of byte array API addition
I still think returning 0 regardless of the input range is wrong. It feels off when clearly incorrect start or end index, such as negative ones or start greater than end, results in 0 return instead of an IOOBE. I think we should reject null or treat null as 0 length to solve this inconsistency.
Also, I think a name like hashCodeOfRange serves better, like copyOfRange.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/24128#issuecomment-3620446510
PR Comment: https://git.openjdk.org/jdk/pull/24128#issuecomment-3620447793
More information about the core-libs-dev
mailing list