diff --git a/jdk/src/java.base/share/classes/java/text/ChoiceFormat.java b/jdk/src/java.base/share/classes/java/text/ChoiceFormat.java index 98c66365c1b..e8fa564ec26 100644 --- a/jdk/src/java.base/share/classes/java/text/ChoiceFormat.java +++ b/jdk/src/java.base/share/classes/java/text/ChoiceFormat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2017, 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 @@ -172,6 +172,8 @@ public class ChoiceFormat extends NumberFormat { /** * Sets the pattern. * @param newPattern See the class description. + * @exception NullPointerException if {@code newPattern} + * is {@code null} */ public void applyPattern(String newPattern) { StringBuffer[] segments = new StringBuffer[2]; @@ -309,6 +311,8 @@ public class ChoiceFormat extends NumberFormat { * Constructs with limits and corresponding formats based on the pattern. * * @param newPattern the new pattern string + * @exception NullPointerExcpetion if {@code newPattern} is + * {@code null} * @see #applyPattern */ public ChoiceFormat(String newPattern) { @@ -320,6 +324,8 @@ public class ChoiceFormat extends NumberFormat { * * @param limits limits in ascending order * @param formats corresponding format strings + * @exception NullPointerException if {@code limits} or {@code formats} + * is {@code null} * @see #setChoices */ public ChoiceFormat(double[] limits, String[] formats) { @@ -339,6 +345,8 @@ public class ChoiceFormat extends NumberFormat { * When formatting with object Y, * if the object is a NumberFormat, then ((NumberFormat) Y).format(X) * is called. Otherwise Y.toString() is called. + * @exception NullPointerException if {@code limits} or + * {@code formats} is {@code null} */ public void setChoices(double[] limits, String formats[]) { if (limits.length != formats.length) { @@ -386,6 +394,8 @@ public class ChoiceFormat extends NumberFormat { * @param number number to be formatted and substituted. * @param toAppendTo where text is appended. * @param status ignore no useful status is returned. + * @exception NullPointerException if {@code toAppendTo} + * is {@code null} */ public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition status) { @@ -414,6 +424,9 @@ public class ChoiceFormat extends NumberFormat { * status.index is unchanged and status.errorIndex is set to the * first index of the character that caused the parse to fail. * @return A Number representing the value of the number parsed. + * @exception NullPointerException if {@code status} is {@code null} + * or if {@code text} is {@code null} and the list of + * choice strings is not empty. */ public Number parse(String text, ParsePosition status) { // find the best number (defined as the one with the longest parse) diff --git a/jdk/src/java.base/share/classes/java/text/DateFormat.java b/jdk/src/java.base/share/classes/java/text/DateFormat.java index 3072dec87b4..3b689b534f3 100644 --- a/jdk/src/java.base/share/classes/java/text/DateFormat.java +++ b/jdk/src/java.base/share/classes/java/text/DateFormat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2017, 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 @@ -141,6 +141,25 @@ import sun.util.locale.provider.LocaleServiceProviderPool; * If multiple threads access a format concurrently, it must be synchronized * externally. * + * @implSpec + *
arguments array is not of the type
* expected by the format element(s) that use it.
+ * @exception NullPointerException if {@code result} is {@code null}
*/
public final StringBuffer format(Object[] arguments, StringBuffer result,
FieldPosition pos)
@@ -835,6 +842,7 @@ public class MessageFormat extends Format {
* or if an argument in the arguments array
* is not of the type expected by the format element(s)
* that use it.
+ * @exception NullPointerException if {@code pattern} is {@code null}
*/
public static String format(String pattern, Object ... arguments) {
MessageFormat temp = new MessageFormat(pattern);
@@ -858,6 +866,7 @@ public class MessageFormat extends Format {
* @exception IllegalArgumentException if an argument in the
* arguments array is not of the type
* expected by the format element(s) that use it.
+ * @exception NullPointerException if {@code result} is {@code null}
*/
public final StringBuffer format(Object arguments, StringBuffer result,
FieldPosition pos)
@@ -947,6 +956,8 @@ public class MessageFormat extends Format {
* @param source the string to parse
* @param pos the parse position
* @return an array of parsed objects
+ * @exception NullPointerException if {@code pos} is {@code null}
+ * for a non-null {@code source} string.
*/
public Object[] parse(String source, ParsePosition pos) {
if (source == null) {
diff --git a/jdk/src/java.base/share/classes/java/text/NumberFormat.java b/jdk/src/java.base/share/classes/java/text/NumberFormat.java
index 68f30d12563..73dbfea6dab 100644
--- a/jdk/src/java.base/share/classes/java/text/NumberFormat.java
+++ b/jdk/src/java.base/share/classes/java/text/NumberFormat.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, 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
@@ -174,6 +174,13 @@ import sun.util.locale.provider.LocaleServiceProviderPool;
* If multiple threads access a format concurrently, it must be synchronized
* externally.
*
+ * @implSpec The {@link #format(double, StringBuffer, FieldPosition)},
+ * {@link #format(long, StringBuffer, FieldPosition)} and
+ * {@link #parse(String, ParsePosition)} methods may throw
+ * {@code NullPointerException}, if any of their parameter is {@code null}.
+ * The subclass may provide its own implementation and specification about
+ * {@code NullPointerException}.
+ *
* @see DecimalFormat
* @see ChoiceFormat
* @author Mark Davis
diff --git a/jdk/src/java.base/share/classes/java/text/SimpleDateFormat.java b/jdk/src/java.base/share/classes/java/text/SimpleDateFormat.java
index d6d6787c72f..00b2b969670 100644
--- a/jdk/src/java.base/share/classes/java/text/SimpleDateFormat.java
+++ b/jdk/src/java.base/share/classes/java/text/SimpleDateFormat.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, 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
@@ -905,6 +905,7 @@ public class SimpleDateFormat extends DateFormat {
* @param startDate During parsing, two digit years will be placed in the range
* startDate to startDate + 100 years.
* @see #get2DigitYearStart
+ * @throws NullPointerException if {@code startDate} is {@code null}.
* @since 1.2
*/
public void set2DigitYearStart(Date startDate) {
@@ -933,7 +934,7 @@ public class SimpleDateFormat extends DateFormat {
* @param pos the formatting position. On input: an alignment field,
* if desired. On output: the offsets of the alignment field.
* @return the formatted date-time string.
- * @exception NullPointerException if the given {@code date} is {@code null}.
+ * @exception NullPointerException if any of the parameters is {@code null}.
*/
@Override
public StringBuffer format(Date date, StringBuffer toAppendTo,