8177418: NPE is not apparent for methods in java.util.TimeZone API docs

Reviewed-by: lancea, naoto
This commit is contained in:
Justin Lu 2023-01-27 18:11:20 +00:00 committed by Naoto Sato
parent 7aaf76c529
commit 22c976a9b0
2 changed files with 19 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -839,8 +839,12 @@ public class SimpleTimeZone extends TimeZone {
/**
* Queries if the given date is in daylight saving time.
* @implSpec The default implementation throws a
* {@code NullPointerException} if {@code date} is {@code null}
* @return true if daylight saving time is in effective at the
* given date; false otherwise.
* @throws NullPointerException This method may throw a
* {@code NullPointerException} if {@code date} is {@code null}
*/
public boolean inDaylightTime(Date date)
{

View File

@ -295,7 +295,11 @@ public abstract class TimeZone implements Serializable, Cloneable {
/**
* Sets the time zone ID. This does not change any other data in
* the time zone object.
* @implSpec The default implementation throws a
* {@code NullPointerException} if {@code ID} is {@code null}
* @param ID the new time zone ID.
* @throws NullPointerException This method may throw a
* {@code NullPointerException} if {@code ID} is {@code null}
*/
public void setID(String ID)
{
@ -403,13 +407,18 @@ public abstract class TimeZone implements Serializable, Cloneable {
* found, the name is returned. Otherwise, a string in the
* <a href="#NormalizedCustomID">normalized custom ID format</a> is returned.
*
* @implSpec The default implementation throws an
* {@code IllegalArgumentException} if {@code style} is invalid or a
* {@code NullPointerException} if {@code ID} is {@code null}.
* @param daylight {@code true} specifying a Daylight Saving Time name, or
* {@code false} specifying a Standard Time name
* @param style either {@link #LONG} or {@link #SHORT}
* @param locale the locale in which to supply the display name.
* @return the human-readable name of this time zone in the given locale.
* @throws IllegalArgumentException if {@code style} is invalid.
* @throws NullPointerException if {@code locale} is {@code null}.
* @throws IllegalArgumentException This method may throw an
* {@code IllegalArgumentException} if {@code style} is invalid.
* @throws NullPointerException This method may throw a
* {@code NullPointerException} if {@code ID} is {@code null}
* @since 1.2
* @see java.text.DateFormatSymbols#getZoneStrings()
*/
@ -519,6 +528,8 @@ public abstract class TimeZone implements Serializable, Cloneable {
* @param date the given Date.
* @return {@code true} if the given date is in Daylight Saving Time,
* {@code false}, otherwise.
* @throws NullPointerException This method may throw a
* {@code NullPointerException} if {@code date} is {@code null}
*/
public abstract boolean inDaylightTime(Date date);
@ -532,6 +543,7 @@ public abstract class TimeZone implements Serializable, Cloneable {
*
* @return the specified {@code TimeZone}, or the GMT zone if the given ID
* cannot be understood.
* @throws NullPointerException if {@code ID} is {@code null}
*/
public static synchronized TimeZone getTimeZone(String ID) {
return getTimeZone(ID, true);