RFR: 8332826: Make hashCode methods in ArraysSupport friendlier [v2]

Chen Liang liach at openjdk.org
Wed May 29 03:24:01 UTC 2024


On Tue, 28 May 2024 22:20:39 GMT, Pavel Rappo <prappo at openjdk.org> wrote:

>> I believe, it should be `1`. Hear me out. In this method, the `length` is scaled down, whereas in `StringUTF16` it is not. In this method, it's `length`, in `StringUTF16` it's `((byte[]) value).length`.
>
> In fact, if I change it to `2`, the following tests will fail:
> 
>   - `jdk/jdk/classfile/Utf8EntryTest.java`
>   - `jdk/java/util/zip/ZipCoding.java`
>   - `jdk/java/text/Format/MessageFormat/MessageRegression.java`

Indeed, the actual length passed at call site is `value.length >> 1` instead of `value.length`; this adjusted char-length carries on to `vectorizedHashCode` call.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19414#discussion_r1618126401



More information about the security-dev mailing list