On Mon, 19 Sep 2022 22:07:13 GMT, Joe Wang <jo...@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

Reply via email to