8294008: Grapheme implementation of setText() throws IndexOutOfBoundsException
Reviewed-by: joehw, smarks
This commit is contained in:
parent
df8ec09f8d
commit
e3358e77f5
@ -317,7 +317,15 @@ public class BreakIteratorProviderImpl extends BreakIteratorProvider
|
||||
}
|
||||
}
|
||||
|
||||
// Implementation only for calling Grapheme.nextBoundary()
|
||||
/**
|
||||
* Implementation only for calling Grapheme.nextBoundary().
|
||||
*
|
||||
* 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. The calling
|
||||
* code in GraphemeBreakIterator takes care to ensure that only valid indexes
|
||||
* into the src are used.
|
||||
*/
|
||||
static final class CharacterIteratorCharSequence implements CharSequence {
|
||||
CharacterIterator src;
|
||||
CharacterIteratorCharSequence(CharacterIterator ci) {
|
||||
@ -326,7 +334,10 @@ public class BreakIteratorProviderImpl extends BreakIteratorProvider
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return src.getEndIndex() - src.getBeginIndex();
|
||||
// Return the entire CharSequence length (0 to endIndex), not to
|
||||
// be confused with the text range length (beginIndex to endIndex)
|
||||
// of the underlying CharacterIterator.
|
||||
return src.getEndIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,6 +26,7 @@
|
||||
* @bug 4035266 4052418 4068133 4068137 4068139 4086052 4095322 4097779
|
||||
* 4097920 4098467 4111338 4113835 4117554 4143071 4146175 4152117
|
||||
* 4152416 4153072 4158381 4214367 4217703 4638433 8264765 8291660
|
||||
* 8294008
|
||||
* @library /java/text/testlib
|
||||
* @run main/timeout=2000 BreakIteratorTest
|
||||
* @summary test BreakIterator
|
||||
@ -1468,4 +1469,8 @@ public class BreakIteratorTest extends IntlTest
|
||||
generalIteratorTest(characterBreak, expected);
|
||||
});
|
||||
}
|
||||
|
||||
public void TestSetTextIOOBException() {
|
||||
BreakIterator.getCharacterInstance().setText(new StringCharacterIterator("abcfefg", 1, 5, 3));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user