Skip to content

Commit 7754ac0

Browse files
author
Justin Lu
committedAug 31, 2023
8314925: ChoiceFormat does not specify IllegalArgumentExceptions
Reviewed-by: naoto
1 parent 2264667 commit 7754ac0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed
 

‎src/java.base/share/classes/java/text/ChoiceFormat.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ public class ChoiceFormat extends NumberFormat {
176176
* @param newPattern See the class description.
177177
* @throws NullPointerException if {@code newPattern}
178178
* is {@code null}
179+
* @throws IllegalArgumentException if {@code newPattern}
180+
* is invalid
179181
*/
180182
public void applyPattern(String newPattern) {
181183
StringBuilder[] segments = new StringBuilder[2];
@@ -315,6 +317,8 @@ public String toPattern() {
315317
* @param newPattern the new pattern string
316318
* @throws NullPointerException if {@code newPattern} is
317319
* {@code null}
320+
* @throws IllegalArgumentException if {@code newPattern}
321+
* is invalid
318322
* @see #applyPattern
319323
*/
320324
public ChoiceFormat(String newPattern) {
@@ -328,6 +332,8 @@ public ChoiceFormat(String newPattern) {
328332
* @param formats corresponding format strings
329333
* @throws NullPointerException if {@code limits} or {@code formats}
330334
* is {@code null}
335+
* @throws IllegalArgumentException if the length of {@code limits}
336+
* and {@code formats} are not equal
331337
* @see #setChoices
332338
*/
333339
public ChoiceFormat(double[] limits, String[] formats) {
@@ -345,11 +351,13 @@ public ChoiceFormat(double[] limits, String[] formats) {
345351
* @param formats are the formats you want to use for each limit.
346352
* @throws NullPointerException if {@code limits} or
347353
* {@code formats} is {@code null}
354+
* @throws IllegalArgumentException if the length of {@code limits}
355+
* and {@code formats} are not equal
348356
*/
349357
public void setChoices(double[] limits, String[] formats) {
350358
if (limits.length != formats.length) {
351359
throw new IllegalArgumentException(
352-
"Array and limit arrays must be of the same length.");
360+
"Input arrays must be of the same length.");
353361
}
354362
choiceLimits = Arrays.copyOf(limits, limits.length);
355363
choiceFormats = Arrays.copyOf(formats, formats.length);

0 commit comments

Comments
 (0)
Please sign in to comment.