On Fri, 14 Aug 2026 13:58:59 GMT, Tatsunori Uchino <[email protected]> wrote:
>> Adds `codePointCount()` overloads to `String`, `Character`,
>> `(Abstract)StringBuilder`, and `StringBuffer` to make it possible to
>> conveniently retrieve the length of a string as code points without extra
>> boundary checks.
>>
>>
>> if (superTremendouslyLongExpressionYieldingAString().codePointCount() >
>> limit) {
>> throw new Exception("exceeding length");
>> }
>>
>>
>> Is a CSR required to this change?
>>
>> - [x] I confirm that I make this contribution in accordance with the
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Tatsunori Uchino has updated the pull request incrementally with one
> additional commit since the last revision:
>
> Change "isolated surrogate code unit" to "unpaired surrogate"
Adding test assertions to test/jdk/java/lang/String/Supplementary.java seems
like the right place to me. Its `test8` method is where the
`codePointCount(beg, end)` is already tested, so tests for the no-arg method
seem like they belong in that method or perhaps nearby.
I observe that the `test8` method has a loop that tests all subranges from (0,
len)..(len, len) and another loop that tests (0, 0)..(0, len) using the two-arg
method. It *also* takes a substring over those subranges and tests the result
of `substr.codePointCount(0, substr.length())`. An additional check could be
inserted in the appropriate place in the two loops that tests the result of
`substr.codePointCount()`. That would provide more case coverage of the new
no-arg method.
I have a couple additional minor comments on the test that I'll leave in the
source code.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/26461#issuecomment-5363626709