Summary
Specify missing IllegalArgumentExceptions in java.text.ChoiceFormat.
Problem
java.text.ChoiceFormat contains two methods, setChoices(double[] limits, String[] formats) and applyPattern(String newPattern) which can both throw an IAE. In addition, their associated constructors that call them can also throw an IAE. This is not specified in the documentation.
Solution
Add @throws tags where necessary to conform the spec to the implementation.
Specification
--- a/src/java.base/share/classes/java/text/ChoiceFormat.java
+++ b/src/java.base/share/classes/java/text/ChoiceFormat.java
@@ -176,6 +176,8 @@ public class ChoiceFormat extends NumberFormat {
* @param newPattern See the class description.
* @throws NullPointerException if {@code newPattern}
* is {@code null}
+ * @throws IllegalArgumentException if {@code newPattern}
+ * is invalid
*/
public void applyPattern(String newPattern) {
@@ -315,6 +317,8 @@ public String toPattern() {
* @param newPattern the new pattern string
* @throws NullPointerException if {@code newPattern} is
* {@code null}
+ * @throws IllegalArgumentException if {@code newPattern}
+ * is invalid
* @see #applyPattern
*/
public ChoiceFormat(String newPattern) {
@@ -328,6 +332,8 @@ public ChoiceFormat(String newPattern) {
* @param formats corresponding format strings
* @throws NullPointerException if {@code limits} or {@code formats}
* is {@code null}
+ * @throws IllegalArgumentException if the length of {@code limits}
+ * and {@code formats} are not equal
* @see #setChoices
*/
public ChoiceFormat(limits, formats) {
@@ -345,11 +351,13 @@ public ChoiceFormat(limits, formats) {
* @param formats are the formats you want to use for each limit.
* @throws NullPointerException if {@code limits} or
* {@code formats} is {@code null}
+ * @throws IllegalArgumentException if the length of {@code limits}
+ * and {@code formats} are not equal
*/
public void setChoices(limits, formats) {
- csr of
-
JDK-8314925 ChoiceFormat does not specify IllegalArgumentExceptions
-
- Resolved
-