8039165: [Doc] MessageFormat null locale generates NullPointerException

Reviewed-by: naoto
This commit is contained in:
Justin Lu 2023-07-25 18:26:23 +00:00
parent 36f3bae556
commit c6396dceb9
3 changed files with 100 additions and 67 deletions

View file

@ -391,11 +391,19 @@ public class MessageFormat extends Format {
* Patterns and their interpretation are specified in the
* <a href="#patterns">class description</a>.
*
* @implSpec The default implementation throws a
* {@code NullPointerException} if {@code locale} is {@code null}
* either during the creation of the {@code MessageFormat} object or later
* when {@code format()} is called by a {@code MessageFormat}
* instance with a null locale and the implementation utilizes a
* locale-dependent subformat.
*
* @param pattern the pattern for this message format
* @param locale the locale for this message format
* @throws IllegalArgumentException if the pattern is invalid
* @throws NullPointerException if {@code pattern} is
* {@code null}
* {@code null} or {@code locale} is {@code null} and the
* implementation uses a locale-dependent subformat.
* @since 1.4
*/
public MessageFormat(String pattern, Locale locale) {
@ -844,7 +852,10 @@ public class MessageFormat extends Format {
* @throws IllegalArgumentException if an argument in the
* {@code arguments} array is not of the type
* expected by the format element(s) that use it.
* @throws NullPointerException if {@code result} is {@code null}
* @throws NullPointerException if {@code result} is {@code null} or
* if the {@code MessageFormat} instance that calls this method
* has locale set to null, and the implementation
* uses a locale-dependent subformat.
*/
public final StringBuffer format(Object[] arguments, StringBuffer result,
FieldPosition pos)
@ -890,7 +901,10 @@ public class MessageFormat extends Format {
* @throws IllegalArgumentException if an argument in the
* {@code arguments} array is not of the type
* expected by the format element(s) that use it.
* @throws NullPointerException if {@code result} is {@code null}
* @throws NullPointerException if {@code result} is {@code null} or
* if the {@code MessageFormat} instance that calls this method
* has locale set to null, and the implementation
* uses a locale-dependent subformat.
*/
public final StringBuffer format(Object arguments, StringBuffer result,
FieldPosition pos)