RFR: 8361842: Validate input in both Java and C++ for java.lang.StringCoding intrinsics
ExE Boss
duke at openjdk.org
Thu Jul 10 12:58:56 UTC 2025
On Fri, 27 Jun 2025 13:24:52 GMT, Chen Liang <liach at openjdk.org> wrote:
>> But the original code already checks for `len >= 0`, right? See `LibraryCallKit::inline_countPositives` -> `generate_string_range_check` -> `// Offset and count must not be negative`
>>
>> This PR is about moving the range checks from the intrinsics into the Java wrappers. Removing range checks is out of the scope and should be carefully evaluated on a case-by-case basis separately.
>
> My point is this is a performance-sensitive API. We are using a known-slow check method `checkFromIndexSize` which may introduce a performance regression.
Maybe use `jdk.internal.util.Preconditions` directly instead?
Suggestion:
Preconditions.checkFromIndexSize(off, len, ba.length, null);
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25998#discussion_r2172823303
More information about the hotspot-dev
mailing list