RFR: 8364007: Add no-argument codePointCount method to CharSequence and String [v7]

Tatsunori Uchino duke at openjdk.org
Tue Jan 27 11:33:21 UTC 2026


> 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:

  Replace "unpaired surrogates" with "isolated surrogate code units"
  
  https://www.unicode.org/versions/Unicode17.0.0/core-spec/chapter-3/#G1654
  https://www.unicode.org/charts/PDF/UDC00.pdf

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/26461/files
  - new: https://git.openjdk.org/jdk/pull/26461/files/9af51fc7..471b4308

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=26461&range=06
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=26461&range=05-06

  Stats: 4 lines in 3 files changed: 0 ins; 0 del; 4 mod
  Patch: https://git.openjdk.org/jdk/pull/26461.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/26461/head:pull/26461

PR: https://git.openjdk.org/jdk/pull/26461


More information about the core-libs-dev mailing list