On Mon, 9 Mar 2026 10:17:38 GMT, Volkan Yazici <[email protected]> wrote:

> Improve input validation checks and documentation of the 
> `java.lang.StringUTF16` intrinsics.

src/java.base/share/classes/java/lang/StringUTF16.java line 106:

> 104:     @IntrinsicCandidate
> 105:     static void putChar(byte[] val, int index, int c) {
> 106:         assert val != null && index >= 0 && index < length(val) : 
> "Trusted caller violated input constraints";

`putChar`/`getChar` is on several hot spots. Refrained from guarding it further 
due to performance considerations.

test/hotspot/jtreg/compiler/intrinsics/string/TestStringIntrinsicRangeChecks.java
 line 91:

> 89:         for (int srcOff = 0; srcOff < SIZE; ++srcOff) {
> 90:             for (int dstOff = 0; dstOff < SIZE; ++dstOff) {
> 91:                 for (int len = 0; len < SIZE; ++len) {

I'd have preferred dedicated `@Test` methods fuzzing arguments of associated 
intrinsics using edge cases. For instance, negative (i.e., `< 0`) and excessive 
(i.e., `> SIZE`) index values are missing in these tests. I avoided these and 
similar test improvements to keep the PR focused. Maybe in a follow-up PR.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/30139#discussion_r2904501671
PR Review Comment: https://git.openjdk.org/jdk/pull/30139#discussion_r2904524493

Reply via email to