RFR: 8367129: Move input validation checks to Java for java.lang.StringLatin1 intrinsics
Damon Fenacci
dfenacci at openjdk.org
Wed Feb 11 09:35:35 UTC 2026
On Mon, 15 Dec 2025 20:30:51 GMT, Volkan Yazici <vyazici at openjdk.org> wrote:
> Moves input validation checks to Java for `java.lang.StringLatin1` intrinsics. While doing so, affected `java.lang.StringUTF16` methods needed to be updated due to relaxed checks at intrinsics. The javadocs of the touched methods are extensively overhauled.
Thanks for looking into this @vy! I left a couple of comments/questions (I've mostly checked the intrinsic part).
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") \
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.
src/java.base/share/classes/java/lang/StringLatin1.java line 172:
> 170: Objects.requireNonNull(other);
> 171: String.checkOffset(len1, length(value));
> 172: String.checkOffset(len2, length(other));
Are these additional checks? I'm asking because I was expecting them to "replace" intrinsics ones but couldn't find where/how (if so I'm also wondering why they were not there before: did all callers ensure that?).
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)
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)
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.
-------------
PR Review: https://git.openjdk.org/jdk/pull/28832#pullrequestreview-3777437085
PR Review Comment: https://git.openjdk.org/jdk/pull/28832#discussion_r2786516405
PR Review Comment: https://git.openjdk.org/jdk/pull/28832#discussion_r2786502065
PR Review Comment: https://git.openjdk.org/jdk/pull/28832#discussion_r2788781455
PR Review Comment: https://git.openjdk.org/jdk/pull/28832#discussion_r2788831821
PR Review Comment: https://git.openjdk.org/jdk/pull/28832#discussion_r2788869295
PR Review Comment: https://git.openjdk.org/jdk/pull/28832#discussion_r2786504049
More information about the core-libs-dev
mailing list