MessageFormat in java/text: changed setFormat(int FormatElement, Format newFormat) ArrayIndexOutOfBoundsException because update does not have maxOffset
@@ -690,8 +690,11 @@ public class MessageFormat extends Format {
* larger than the number of format elements in the pattern string
*/
public void setFormat(int formatElementIndex, Format newFormat) {
+ // Android-added: prevent setting unused formatters.
if (formatElementIndex > maxOffset) {
- throw new ArrayIndexOutOfBoundsException(maxOffset, formatElementIndex);
+ // Note: maxOffset is maximum index, not the length.
+ throw new ArrayIndexOutOfBoundsException(
+ "maxOffset=" + maxOffset + "; formatElementIndex=" + formatElementIndex);
}
formats[formatElementIndex] = newFormat;
}
