8187551: MessageFormat.setFormat(int, Format) AIOOBE not thrown when documented

Reviewed-by: naoto, rriggs
This commit is contained in:
Nishit Jain 2017-12-06 11:21:04 +05:30 committed by Nishit Jain
parent 448f3c1fcd
commit fa64310889
2 changed files with 46 additions and 2 deletions

View file

@ -701,6 +701,10 @@ public class MessageFormat extends Format {
* larger than the number of format elements in the pattern string
*/
public void setFormat(int formatElementIndex, Format newFormat) {
if (formatElementIndex > maxOffset) {
throw new ArrayIndexOutOfBoundsException(formatElementIndex);
}
formats[formatElementIndex] = newFormat;
}