src/share/classes/java/lang/String.java

Print this page
rev 6406 : 4247235: (spec str) StringBuffer.insert(int, char[]) specification is inconsistent
Summary: Add blanket null-handling statement to StringBuilder and StringBuffer
Reviewed-by: mduigou

*** 31,40 **** --- 31,41 ---- import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Formatter; import java.util.Locale; + import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; /**
*** 869,878 **** --- 870,881 ---- throw new StringIndexOutOfBoundsException(srcEnd); } if (srcBegin > srcEnd) { throw new StringIndexOutOfBoundsException(srcEnd - srcBegin); } + Objects.requireNonNull(dst); + int j = dstBegin; int n = srcEnd; int i = srcBegin; char[] val = value; /* avoid getfield opcode */
*** 2110,2120 **** * Returns true if and only if this string contains the specified * sequence of char values. * * @param s the sequence to search for * @return true if this string contains {@code s}, false otherwise - * @throws NullPointerException if {@code s} is {@code null} * @since 1.5 */ public boolean contains(CharSequence s) { return indexOf(s.toString()) > -1; } --- 2113,2122 ----
*** 2217,2228 **** * "ba" rather than "ab". * * @param target The sequence of char values to be replaced * @param replacement The replacement sequence of char values * @return The resulting string - * @throws NullPointerException if {@code target} or - * {@code replacement} is {@code null}. * @since 1.5 */ public String replace(CharSequence target, CharSequence replacement) { return Pattern.compile(target.toString(), Pattern.LITERAL).matcher( this).replaceAll(Matcher.quoteReplacement(replacement.toString())); --- 2219,2228 ----
*** 2831,2843 **** * illegal conditions. For specification of all possible * formatting errors, see the <a * href="../util/Formatter.html#detail">Details</a> section of the * formatter class specification. * - * @throws NullPointerException - * If the {@code format} is {@code null} - * * @return A formatted string * * @see java.util.Formatter * @since 1.5 */ --- 2831,2840 ----
*** 2863,2887 **** * extra arguments are ignored. The number of arguments is * variable and may be zero. The maximum number of arguments is * limited by the maximum dimension of a Java array as defined by * <cite>The Java&trade; Virtual Machine Specification</cite>. * The behaviour on a ! * {@code null} argument depends on the <a ! * href="../util/Formatter.html#syntax">conversion</a>. * * @throws java.util.IllegalFormatException * If a format string contains an illegal syntax, a format * specifier that is incompatible with the given arguments, * insufficient arguments given the format string, or other * illegal conditions. For specification of all possible * formatting errors, see the <a * href="../util/Formatter.html#detail">Details</a> section of the * formatter class specification * - * @throws NullPointerException - * If the {@code format} is {@code null} - * * @return A formatted string * * @see java.util.Formatter * @since 1.5 */ --- 2860,2881 ---- * extra arguments are ignored. The number of arguments is * variable and may be zero. The maximum number of arguments is * limited by the maximum dimension of a Java array as defined by * <cite>The Java&trade; Virtual Machine Specification</cite>. * The behaviour on a ! * {@code null} argument depends on the ! * <a href="../util/Formatter.html#syntax">conversion</a>. * * @throws java.util.IllegalFormatException * If a format string contains an illegal syntax, a format * specifier that is incompatible with the given arguments, * insufficient arguments given the format string, or other * illegal conditions. For specification of all possible * formatting errors, see the <a * href="../util/Formatter.html#detail">Details</a> section of the * formatter class specification * * @return A formatted string * * @see java.util.Formatter * @since 1.5 */