<i18n dev> RFR: 8294008: Grapheme implementation of setText() throws IndexOutOfBoundsException [v2]

Naoto Sato naoto at openjdk.org
Mon Sep 19 22:21:45 UTC 2022


On Mon, 19 Sep 2022 22:07:13 GMT, Joe Wang <joehw at openjdk.org> wrote:

>> It's somewhat confusing as this class adapts `CharacterIterator` into `CharSequence` which are similar to each other (thus the bug). Those `beginIndex`/`endIndex` designate the range in the source `CharacterIterator`, and this `length()` method should return the entire text length of the `CharSequence` nevertheless, thus it should start from `0` to `endIndex`.
>
> Yeah, I saw there's a mismatch between the src and limit in this call that led to the index check Exception:
> 286             for (int b = ci.getBeginIndex(); b < end;) {
> 287                 boundaries.add(b);
> 288                 b = Grapheme.nextBoundary(text, b, end);
> 289             }
> 
> and nextBoundary could walk through the entire CharSequence. Maybe it's worth a note to the length() method.

Thanks, Joe. Added comment to the method.

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

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


More information about the i18n-dev mailing list