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

Naoto Sato naoto at openjdk.org
Tue Sep 20 01:14:39 UTC 2022


On Mon, 19 Sep 2022 23:04:12 GMT, Stuart Marks <smarks at openjdk.org> wrote:

>> Thanks, Joe. Added comment to the method.
>
> 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 😀

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

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


More information about the i18n-dev mailing list