<i18n dev> RFR: 8314925: ChoiceFormat does not specify IllegalArgumentExceptions

Justin Lu jlu at openjdk.org
Tue Aug 29 17:01:32 UTC 2023


On Tue, 29 Aug 2023 16:53:29 GMT, Justin Lu <jlu at openjdk.org> wrote:

> Please review this PR and [CSR](https://bugs.openjdk.org/browse/JDK-8315148) which is a conformance change to specify exceptions in java.text.ChoiceFormat.
> 
> Makes `IllegalArgumentException` apparent for `applyPattern` and `setChoices`, as well as for the associated constructors that call the methods.
> 
> This change also improves the error message for the `setChoices` IAE.

src/java.base/share/classes/java/text/ChoiceFormat.java line 180:

> 178:      *            is {@code null}
> 179:      * @throws    IllegalArgumentException if {@code newPattern}
> 180:      *            is invalid

This would probably more informative if it was changed to `IllegalArgumentException if {@code newPattern} violates the ChoiceFormat pattern syntax`.

However, as of now I kept it this way because there is no defined syntax ATM (although I have a PR for that here -> https://github.com/openjdk/jdk/pull/15392) and the other Format classes all also follow the "... is invalid" wording.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/15473#discussion_r1309114867


More information about the i18n-dev mailing list