On Mon, 17 Jul 2023 21:54:37 GMT, Naoto Sato <na...@openjdk.org> wrote:
>> Justin Lu has updated the pull request incrementally with two additional >> commits since the last revision: >> >> - Slight wording adjustment >> - Review: Explicitly declare when NPE thrown instead of 'may' > > src/java.base/share/classes/java/text/MessageFormat.java line 396: > >> 394: * {@code NullPointerException} if {@code locale} is {@code null} >> 395: * either during the creation of the {@code MessageFormat} object >> or later >> 396: * when {@code format()} is called by the constructed {@code >> MessageFormat} object. > > It looks a bit vague as it contains `may`. I think it would be clearer if it > explains a bit more, e.g., it throws NPE if any of the subformats require the > locale, or along with those lines. Probably the same wording is needed at > `format()` and other public methods that use the `locale` field. The only other public methods that use `locale` are setLocale(), getLocale(), toString(), and equals(). In all of these cases I don't believe if a MessageFormat that was created with a null locale (and did not throw NPE) calls them, a NPE will occur in any case. Thus I have updated the spec to not use 'may' and explicitly state NPE is thrown if a subformat is localized and needed by the MessageFormat. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/14911#discussion_r1267298674