RFR: 8366517: `DateFormatSymbols(Locale)` throws NPE if `Locale` argument is null
Roger Riggs
rriggs at openjdk.org
Wed Sep 3 01:00:59 UTC 2025
On Tue, 2 Sep 2025 19:29:37 GMT, Naoto Sato <naoto at openjdk.org> wrote:
> Adding a `@throws` clause for NPE in `java.text.DateFormatSymbols(Locale)` constructor. The bug suggests it should throw a `MissingResourceException`, but I don't think we can change this long standing behavior. Instead, explicitly specify the NPE in the javadoc.
src/java.base/share/classes/java/text/DateFormatSymbols.java line 148:
> 146: * if the resources for the specified locale cannot be
> 147: * found or cannot be loaded.
> 148: * @throws NullPointerException if {@code locale} is null
Adding an explicit Objects.requireNull(locale, "locale") would clearly identify when the NPE is thrown.
Though it might be earlier than without the check.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27060#discussion_r2317509928
More information about the core-libs-dev
mailing list