RFR: 8367129: Move input validation checks to Java for java.lang.StringLatin1 intrinsics [v2]
Volkan Yazici
vyazici at openjdk.org
Thu Feb 12 16:15:14 UTC 2026
On Tue, 10 Feb 2026 08:28:58 GMT, Damon Fenacci <dfenacci at openjdk.org> wrote:
>> Volkan Yazici has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Apply review feedback
>
> src/hotspot/share/classfile/vmIntrinsics.hpp line 402:
>
>> 400: do_signature(indexOfChar_signature, "([BIII)I") \
>> 401: do_intrinsic(_equalsL, java_lang_StringLatin1,equalsS_name, equalsB_signature, F_S) \
>> 402: do_name( equalsS_name, "equals0") \
>
> Suggestion:
>
> do_name( equalsS_name, "equals0") \
Applied the suggestion in 068eb3589a3.
> src/java.base/share/classes/java/lang/StringLatin1.java line 2:
>
>> 1: /*
>> 2: * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
>
> Suggestion:
>
> * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved.
Corrected the copyright year in 068eb3589a3.
> Are these additional checks?
Yes. I'm exercising _"Always validate all input at the Java wrapper"_ stated in the parent issue [JDK-8156534].
> I'm asking because I was expecting them to "replace" intrinsics ones but couldn't find where/how
Note the Javadoc of `ArraysSupport#mismatch(byte[] a, byte[] b, int length)`:
This method does not perform bounds checks. It is the responsibility
of the caller to perform such bounds checks before calling this method.
AFAICT, `ArraysSupport` should be updated to validate its inputs too. But that is for another day.
> I'm also wondering why they were not there before: did all callers ensure that?
Yes, pretty much accidentally.
[JDK-8156534]: https://bugs.openjdk.org/browse/JDK-8156534
> src/java.base/share/classes/java/lang/StringLatin1.java line 220:
>
>> 218: static int compareToUTF16(byte[] value, byte[] other, int len1, int len2) {
>> 219: Objects.requireNonNull(value);
>> 220: Objects.requireNonNull(other);
>
> [Similar question](https://github.com/openjdk/jdk/pull/28832/changes#r2788781455)
Callers were ensuring the validity.
> src/java.base/share/classes/java/lang/StringLatin1.java line 266:
>
>> 264: static int compareToCI_UTF16(byte[] value, byte[] other) {
>> 265: Objects.requireNonNull(value);
>> 266: Objects.requireNonNull(other);
>
> [Similar question](https://github.com/openjdk/jdk/pull/28832/changes#r2788781455)
Caller were ensuring the validity.
> src/java.base/share/classes/java/lang/StringUTF16.java line 2:
>
>> 1: /*
>> 2: * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
>
> Suggestion:
>
> * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved.
Corrected the copyright year in 068eb3589a3.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28832#discussion_r2799748646
PR Review Comment: https://git.openjdk.org/jdk/pull/28832#discussion_r2799749747
PR Review Comment: https://git.openjdk.org/jdk/pull/28832#discussion_r2799752709
PR Review Comment: https://git.openjdk.org/jdk/pull/28832#discussion_r2799754246
PR Review Comment: https://git.openjdk.org/jdk/pull/28832#discussion_r2799754534
PR Review Comment: https://git.openjdk.org/jdk/pull/28832#discussion_r2799755812
More information about the core-libs-dev
mailing list