RFR: 8294008: Grapheme implementation of setText() throws IndexOutOfBoundsException [v3]

Stuart Marks smarks at openjdk.org
Tue Sep 20 15:56:02 UTC 2022


On Tue, 20 Sep 2022 01:09:29 GMT, Naoto Sato <naoto at openjdk.org> wrote:

>> OK yeah this is really confusing. One might ask a similar question in `charAt` about why it doesn't call
>> 
>>     src.setIndex(index + src.getBeginIndex());
>> 
>> The answer is that this is a special-purpose `CharSequence` that represents characters in the index range [0..endIndex) of the underlying `CharacterIterator`, **even if** that `CharacterIterator` represents the subrange of some string. As Joe noted, the calling code in `GraphemeBreakIterator` takes care to ensure that only valid indexes into the `src` are used.
>> 
>> I think the comment on `length` helps a little bit but maybe a class-level comment would be better, since it applies to the whole model of this special `CharSequence` and not just the `length` method. Just a sentence or two is sufficient. Feel free to crib from the above.
>
> Thanks, Stuart. I used the paragraph almost intact for the class description 😀

OK looks good.

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

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


More information about the core-libs-dev mailing list