RFR: 8364007: Add no-argument codePointCount method to CharSequence and String [v15]
Chen Liang
liach at openjdk.org
Fri Jan 30 15:40:36 UTC 2026
On Fri, 30 Jan 2026 15:20:03 GMT, Tatsunori Uchino <duke at openjdk.org> 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?
>
> Tatsunori Uchino has updated the pull request incrementally with one additional commit since the last revision:
>
> Use `codePointCountSB` and add its test
Since we are touching `CharSequence`, we might need to revise `CharBuffer` (through `X-Buffer.java.template`) to specify `codePointCount` is a relative operation.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/26461#issuecomment-3824360182
More information about the core-libs-dev
mailing list