On Thu, 24 Jul 2025 14:50:07 GMT, Tatsunori Uchino <d...@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?

Also, do we need `codePointCount` on `CharSequence`?

src/java.base/share/classes/java/lang/AbstractStringBuilder.java line 545:

> 543:         byte[] value = this.value;
> 544:         if (isLatin1(coder)) {
> 545:             return value.length;

Suggestion:

            return count;

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

PR Review: https://git.openjdk.org/jdk/pull/26461#pullrequestreview-3052346769
PR Review Comment: https://git.openjdk.org/jdk/pull/26461#discussion_r2228974436

Reply via email to