On Mon, 9 Feb 2026 15:24:53 GMT, Zihao Lin <[email protected]> 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 five additional commits since
> the last revision:
>
> - rename to hashCodeOfRange
> - Merge branch 'master' into dev
> - Merge branch 'openjdk:master' into dev
> - Merge branch 'openjdk:master' into dev
> - 8352171: Arrays.hashCode for sub-range of byte array API addition
src/java.base/share/classes/java/util/Arrays.java line 4449:
> 4447: * order. If {@code a} is {@code null}, this method treats the
> array as
> 4448: * having length {@code 0} for range checking and returns {@code 0}
> only
> 4449: * for the empty range {@code [0,0)}.
"**only** for the empty range" may be misunderstood.
I would also rename the parameter to "array", the simple "a" is confusing to
read in the javadoc with only the font change.
Suggestion:
* order. If {@code a} is {@code null}, this method treats the array as
* having length {@code 0} for range checking.
* This method returns {@code 0} if either {@code a} is null or the range
is empty {@code [0,0)}.
Separating the statements allows the first to apply to the range checking in
the @throws clause.
And the second to make it clearer that zero is returned for empty/null ranges.
src/java.base/share/classes/java/util/Arrays.java line 4455:
> 4453: * @param toIndex the final index of the range to be hashed,
> exclusive
> 4454: * @return a content-based hash code for the specified range of the
> array,
> 4455: * or {@code 0} if {@code a} is {@code null} and the range
> is empty
Suggestion:
* or {@code 0} if either {@code a} is {@code null} or the range is
empty
Clarify that either condition is independently sufficient to return 0.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24128#discussion_r2783076663
PR Review Comment: https://git.openjdk.org/jdk/pull/24128#discussion_r2783040185