Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8366735

Refine null locale processing of ctor/factory methods in `Date/DecimalFormatSymbols`

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 26
    • core-libs
    • None
    • low
    • Only behavioral difference is where the NPE occurs and its messages. It does not appear to be significant to applications.
    • Java API
    • SE

      Summary

      Refine the null locale processing of constructors and factory methods in DateFormatSymbols and DecimalFormatSymbols

      Problem

      There is no description in the javadoc of java.text.DateFormatSymbols(Locale) constructor when the argument is null. The implementation throws an NPE, but that is not specified.

      Solution

      Add @throws NullPointerException clause in the javadoc. Also, change the implementation of constructors and factory methods that take locale argument to call Objects.requireNonNull() methods first. That will produce clearer error messages, instead of some internal null reference as in the issue description.

      Specification

      Add the following @throws clause to the javadoc:

      @@ -145,6 +145,7 @@
            * @throws     java.util.MissingResourceException
            *             if the resources for the specified locale cannot be
            *             found or cannot be loaded.
      +     * @throws     NullPointerException if {@code locale} is null
            */

            naoto Naoto Sato
            webbuggrp Webbug Group
            Justin Lu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: