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

Calendar.setTime(Date date) throws NPE with Date date = null

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 16
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      Long standing behavior is to throw NPE so no compatibility impact.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      Calendar.setTime(null) throws NullPointerException. This should be specified.

      Problem

      There is no specification in the method description of Calendar.setTime() about a possible NullPointerException.

      Solution

      Add a @throws tag in the method description.

      Specification

      Add the following line in the method description:

      --- a/src/java.base/share/classes/java/util/Calendar.java
      +++ b/src/java.base/share/classes/java/util/Calendar.java
      @@ -1796,8 +1796,10 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
            * @param date the given Date.
            * @see #getTime()
            * @see #setTimeInMillis(long)
      +     * @throws NullPointerException if {@code date} is {@code null}
            */
           public final void setTime(Date date) {

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              naoto Naoto Sato
              Reporter:
              webbuggrp Webbug Group
              Reviewed By:
              Alan Bateman, Brian Burkhalter, Lance Andersen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: