src/java.base/share/classes/java/lang/StringBuffer.java
author darcy
Wed, 25 Apr 2018 22:12:06 -0700
changeset 49895 661ef62a6618
parent 49203 3a225d9cabe1
child 53653 868611f0adc3
permissions -rw-r--r--
8200478: For boxing conversion javac uses Long.valueOf which does not guarantee caching according to its javadoc Reviewed-by: bpb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
49115
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
     2
 * Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1247
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1247
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1247
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1247
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1247
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.lang;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
    28
import java.util.Arrays;
31671
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 29974
diff changeset
    29
import jdk.internal.HotSpotIntrinsicCandidate;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * A thread-safe, mutable sequence of characters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * A string buffer is like a {@link String}, but can be modified. At any
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * point in time it contains some particular sequence of characters, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * the length and content of the sequence can be changed through certain
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * method calls.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * String buffers are safe for use by multiple threads. The methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * are synchronized where necessary so that all the operations on any
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * particular instance behave as if they occur in some serial order
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * that is consistent with the order of the method calls made by each of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * the individual threads involved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * <p>
13155
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
    44
 * The principal operations on a {@code StringBuffer} are the
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
    45
 * {@code append} and {@code insert} methods, which are
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * overloaded so as to accept data of any type. Each effectively
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * converts a given datum to a string and then appends or inserts the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * characters of that string to the string buffer. The
13155
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
    49
 * {@code append} method always adds these characters at the end
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
    50
 * of the buffer; the {@code insert} method adds the characters at
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * a specified point.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * <p>
13155
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
    53
 * For example, if {@code z} refers to a string buffer object
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
    54
 * whose current contents are {@code "start"}, then
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
    55
 * the method call {@code z.append("le")} would cause the string
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
    56
 * buffer to contain {@code "startle"}, whereas
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
    57
 * {@code z.insert(4, "le")} would alter the string buffer to
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
    58
 * contain {@code "starlet"}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * <p>
13155
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
    60
 * In general, if sb refers to an instance of a {@code StringBuffer},
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
    61
 * then {@code sb.append(x)} has the same effect as
14997
97d6098fd419 8005118: Javadoc styles are inconsistent
jgish
parents: 14332
diff changeset
    62
 * {@code sb.insert(sb.length(), x)}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * Whenever an operation occurs involving a source sequence (such as
13155
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
    65
 * appending or inserting from a source sequence), this class synchronizes
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * only on the string buffer performing the operation, not on the source.
13155
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
    67
 * Note that while {@code StringBuffer} is designed to be safe to use
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
    68
 * concurrently from multiple threads, if the constructor or the
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
    69
 * {@code append} or {@code insert} operation is passed a source sequence
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
    70
 * that is shared across threads, the calling code must ensure
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
    71
 * that the operation has a consistent and unchanging view of the source
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
    72
 * sequence for the duration of the operation.
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
    73
 * This could be satisfied by the caller holding a lock during the
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
    74
 * operation's call, by using an immutable source sequence, or by not
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
    75
 * sharing the source sequence across threads.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * Every string buffer has a capacity. As long as the length of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * character sequence contained in the string buffer does not exceed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * the capacity, it is not necessary to allocate a new internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * buffer array. If the internal buffer overflows, it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * automatically made larger.
15312
4b57f9da8192 4247235: (spec str) StringBuffer.insert(int, char[]) specification is inconsistent
jgish
parents: 14997
diff changeset
    82
 * <p>
4b57f9da8192 4247235: (spec str) StringBuffer.insert(int, char[]) specification is inconsistent
jgish
parents: 14997
diff changeset
    83
 * Unless otherwise noted, passing a {@code null} argument to a constructor
4b57f9da8192 4247235: (spec str) StringBuffer.insert(int, char[]) specification is inconsistent
jgish
parents: 14997
diff changeset
    84
 * or method in this class will cause a {@link NullPointerException} to be
4b57f9da8192 4247235: (spec str) StringBuffer.insert(int, char[]) specification is inconsistent
jgish
parents: 14997
diff changeset
    85
 * thrown.
4b57f9da8192 4247235: (spec str) StringBuffer.insert(int, char[]) specification is inconsistent
jgish
parents: 14997
diff changeset
    86
 * <p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * As of  release JDK 5, this class has been supplemented with an equivalent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * class designed for use by a single thread, {@link StringBuilder}.  The
14997
97d6098fd419 8005118: Javadoc styles are inconsistent
jgish
parents: 14332
diff changeset
    89
 * {@code StringBuilder} class should generally be used in preference to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * this one, as it supports all of the same operations but it is faster, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * it performs no synchronization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 *
49115
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
    93
 * @apiNote
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
    94
 * {@code StringBuffer} implements {@code Comparable} but does not override
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
    95
 * {@link Object#equals equals}. Thus, the natural ordering of {@code StringBuffer}
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
    96
 * is inconsistent with equals. Care should be exercised if {@code StringBuffer}
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
    97
 * objects are used as keys in a {@code SortedMap} or elements in a {@code SortedSet}.
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
    98
 * See {@link Comparable}, {@link java.util.SortedMap SortedMap}, or
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
    99
 * {@link java.util.SortedSet SortedSet} for more information.
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   100
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * @author      Arthur van Hoff
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * @see     java.lang.StringBuilder
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * @see     java.lang.String
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 17709
diff changeset
   104
 * @since   1.0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 public final class StringBuffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    extends AbstractStringBuilder
49115
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   108
    implements java.io.Serializable, Comparable<StringBuffer>, CharSequence
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   111
    /**
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   112
     * A cache of the last value returned by toString. Cleared
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   113
     * whenever the StringBuffer is modified.
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   114
     */
33663
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 31671
diff changeset
   115
    private transient String toStringCache;
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   116
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    /** use serialVersionUID from JDK 1.0.2 for interoperability */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    static final long serialVersionUID = 3388685877147921107L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * Constructs a string buffer with no characters in it and an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * initial capacity of 16 characters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     */
31671
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 29974
diff changeset
   124
    @HotSpotIntrinsicCandidate
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    public StringBuffer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        super(16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * Constructs a string buffer with no characters in it and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * the specified initial capacity.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @param      capacity  the initial capacity.
49203
3a225d9cabe1 8199420: Update javadoc tags in java.lang.System and related
rriggs
parents: 49115
diff changeset
   134
     * @throws     NegativeArraySizeException  if the {@code capacity}
3a225d9cabe1 8199420: Update javadoc tags in java.lang.System and related
rriggs
parents: 49115
diff changeset
   135
     *             argument is less than {@code 0}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     */
31671
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 29974
diff changeset
   137
    @HotSpotIntrinsicCandidate
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    public StringBuffer(int capacity) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        super(capacity);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * Constructs a string buffer initialized to the contents of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * specified string. The initial capacity of the string buffer is
13155
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
   145
     * {@code 16} plus the length of the string argument.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * @param   str   the initial contents of the buffer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     */
31671
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 29974
diff changeset
   149
    @HotSpotIntrinsicCandidate
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    public StringBuffer(String str) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        super(str.length() + 16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        append(str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * Constructs a string buffer that contains the same characters
13155
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
   157
     * as the specified {@code CharSequence}. The initial capacity of
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
   158
     * the string buffer is {@code 16} plus the length of the
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
   159
     * {@code CharSequence} argument.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * <p>
13155
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
   161
     * If the length of the specified {@code CharSequence} is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * less than or equal to zero, then an empty buffer of capacity
13155
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
   163
     * {@code 16} is returned.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @param      seq   the sequence to copy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    public StringBuffer(CharSequence seq) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        this(seq.length() + 16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        append(seq);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
49115
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   173
    /**
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   174
     * Compares two {@code StringBuffer} instances lexicographically. This method
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   175
     * follows the same rules for lexicographical comparison as defined in the
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   176
     * {@linkplain java.lang.CharSequence#compare(java.lang.CharSequence,
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   177
     * java.lang.CharSequence)  CharSequence.compare(this, another)} method.
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   178
     *
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   179
     * <p>
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   180
     * For finer-grained, locale-sensitive String comparison, refer to
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   181
     * {@link java.text.Collator}.
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   182
     *
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   183
     * @implNote
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   184
     * This method synchronizes on {@code this}, the current object, but not
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   185
     * {@code StringBuffer another} with which {@code this StringBuffer} is compared.
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   186
     *
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   187
     * @param another the {@code StringBuffer} to be compared with
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   188
     *
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   189
     * @return  the value {@code 0} if this {@code StringBuffer} contains the same
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   190
     * character sequence as that of the argument {@code StringBuffer}; a negative integer
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   191
     * if this {@code StringBuffer} is lexicographically less than the
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   192
     * {@code StringBuffer} argument; or a positive integer if this {@code StringBuffer}
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   193
     * is lexicographically greater than the {@code StringBuffer} argument.
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   194
     *
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   195
     * @since 11
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   196
     */
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   197
    @Override
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   198
    public synchronized int compareTo(StringBuffer another) {
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   199
        return super.compareTo(another);
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   200
    }
ecfaa82c53be 8137326: Methods for comparing CharSequence, StringBuilder, and StringBuffer
joehw
parents: 47216
diff changeset
   201
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   202
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    public synchronized int length() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        return count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   207
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    public synchronized int capacity() {
33663
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 31671
diff changeset
   209
        return super.capacity();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   213
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    public synchronized void ensureCapacity(int minimumCapacity) {
33663
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 31671
diff changeset
   215
        super.ensureCapacity(minimumCapacity);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * @since      1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   221
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    public synchronized void trimToSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        super.trimToSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * @throws IndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * @see        #length()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   230
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    public synchronized void setLength(int newLength) {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   232
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        super.setLength(newLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * @throws IndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * @see        #length()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   240
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    public synchronized char charAt(int index) {
33663
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 31671
diff changeset
   242
        return super.charAt(index);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    /**
29974
9dea25b5ffba 8048264: StringBuffer's codePoint methods throw unspecified IndexOutOfBoundsException
bchristi
parents: 25859
diff changeset
   246
     * @throws IndexOutOfBoundsException {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * @since      1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   249
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    public synchronized int codePointAt(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        return super.codePointAt(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    /**
29974
9dea25b5ffba 8048264: StringBuffer's codePoint methods throw unspecified IndexOutOfBoundsException
bchristi
parents: 25859
diff changeset
   255
     * @throws IndexOutOfBoundsException {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * @since     1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   258
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    public synchronized int codePointBefore(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        return super.codePointBefore(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    /**
29974
9dea25b5ffba 8048264: StringBuffer's codePoint methods throw unspecified IndexOutOfBoundsException
bchristi
parents: 25859
diff changeset
   264
     * @throws IndexOutOfBoundsException {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * @since     1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   267
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    public synchronized int codePointCount(int beginIndex, int endIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        return super.codePointCount(beginIndex, endIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    /**
29974
9dea25b5ffba 8048264: StringBuffer's codePoint methods throw unspecified IndexOutOfBoundsException
bchristi
parents: 25859
diff changeset
   273
     * @throws IndexOutOfBoundsException {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * @since     1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   276
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    public synchronized int offsetByCodePoints(int index, int codePointOffset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        return super.offsetByCodePoints(index, codePointOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @throws IndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   284
    @Override
1223
5c1037124466 6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents: 2
diff changeset
   285
    public synchronized void getChars(int srcBegin, int srcEnd, char[] dst,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                                      int dstBegin)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        super.getChars(srcBegin, srcEnd, dst, dstBegin);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * @throws IndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * @see        #length()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   295
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    public synchronized void setCharAt(int index, char ch) {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   297
        toStringCache = null;
33663
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 31671
diff changeset
   298
        super.setCharAt(index, ch);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   301
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    public synchronized StringBuffer append(Object obj) {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   303
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        super.append(String.valueOf(obj));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   308
    @Override
31671
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 29974
diff changeset
   309
    @HotSpotIntrinsicCandidate
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    public synchronized StringBuffer append(String str) {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   311
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        super.append(str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    /**
14997
97d6098fd419 8005118: Javadoc styles are inconsistent
jgish
parents: 14332
diff changeset
   317
     * Appends the specified {@code StringBuffer} to this sequence.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * <p>
14997
97d6098fd419 8005118: Javadoc styles are inconsistent
jgish
parents: 14332
diff changeset
   319
     * The characters of the {@code StringBuffer} argument are appended,
97d6098fd419 8005118: Javadoc styles are inconsistent
jgish
parents: 14332
diff changeset
   320
     * in order, to the contents of this {@code StringBuffer}, increasing the
97d6098fd419 8005118: Javadoc styles are inconsistent
jgish
parents: 14332
diff changeset
   321
     * length of this {@code StringBuffer} by the length of the argument.
97d6098fd419 8005118: Javadoc styles are inconsistent
jgish
parents: 14332
diff changeset
   322
     * If {@code sb} is {@code null}, then the four characters
97d6098fd419 8005118: Javadoc styles are inconsistent
jgish
parents: 14332
diff changeset
   323
     * {@code "null"} are appended to this {@code StringBuffer}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * Let <i>n</i> be the length of the old character sequence, the one
14997
97d6098fd419 8005118: Javadoc styles are inconsistent
jgish
parents: 14332
diff changeset
   326
     * contained in the {@code StringBuffer} just prior to execution of the
97d6098fd419 8005118: Javadoc styles are inconsistent
jgish
parents: 14332
diff changeset
   327
     * {@code append} method. Then the character at index <i>k</i> in
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * the new character sequence is equal to the character at index <i>k</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * in the old character sequence, if <i>k</i> is less than <i>n</i>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * otherwise, it is equal to the character at index <i>k-n</i> in the
13155
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
   331
     * argument {@code sb}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * <p>
13155
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
   333
     * This method synchronizes on {@code this}, the destination
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
   334
     * object, but does not synchronize on the source ({@code sb}).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     *
14997
97d6098fd419 8005118: Javadoc styles are inconsistent
jgish
parents: 14332
diff changeset
   336
     * @param   sb   the {@code StringBuffer} to append.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * @return  a reference to this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    public synchronized StringBuffer append(StringBuffer sb) {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   341
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        super.append(sb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   346
    /**
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   347
     * @since 1.8
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   348
     */
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   349
    @Override
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   350
    synchronized StringBuffer append(AbstractStringBuilder asb) {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   351
        toStringCache = null;
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   352
        super.append(asb);
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   353
        return this;
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   354
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    /**
13155
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
   357
     * Appends the specified {@code CharSequence} to this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * sequence.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * <p>
13155
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
   360
     * The characters of the {@code CharSequence} argument are appended,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * in order, increasing the length of this sequence by the length of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * <p>The result of this method is exactly the same as if it were an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * invocation of this.append(s, 0, s.length());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     *
13155
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
   367
     * <p>This method synchronizes on {@code this}, the destination
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
   368
     * object, but does not synchronize on the source ({@code s}).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     *
13155
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
   370
     * <p>If {@code s} is {@code null}, then the four characters
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
   371
     * {@code "null"} are appended.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     *
13155
8140afb39557 7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads
jgish
parents: 5506
diff changeset
   373
     * @param   s the {@code CharSequence} to append.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * @return  a reference to this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   377
    @Override
17709
fc6f678fdb83 8014814: (str) StringBuffer "null" is not appended
dholmes
parents: 17472
diff changeset
   378
    public synchronized StringBuffer append(CharSequence s) {
fc6f678fdb83 8014814: (str) StringBuffer "null" is not appended
dholmes
parents: 17472
diff changeset
   379
        toStringCache = null;
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   380
        super.append(s);
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   381
        return this;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * @throws IndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * @since      1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   388
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    public synchronized StringBuffer append(CharSequence s, int start, int end)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   391
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        super.append(s, start, end);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   396
    @Override
1223
5c1037124466 6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents: 2
diff changeset
   397
    public synchronized StringBuffer append(char[] str) {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   398
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        super.append(str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
1223
5c1037124466 6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents: 2
diff changeset
   403
    /**
5c1037124466 6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents: 2
diff changeset
   404
     * @throws IndexOutOfBoundsException {@inheritDoc}
5c1037124466 6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents: 2
diff changeset
   405
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   406
    @Override
1223
5c1037124466 6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents: 2
diff changeset
   407
    public synchronized StringBuffer append(char[] str, int offset, int len) {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   408
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        super.append(str, offset, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   413
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    public synchronized StringBuffer append(boolean b) {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   415
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        super.append(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   420
    @Override
31671
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 29974
diff changeset
   421
    @HotSpotIntrinsicCandidate
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    public synchronized StringBuffer append(char c) {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   423
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        super.append(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   428
    @Override
31671
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 29974
diff changeset
   429
    @HotSpotIntrinsicCandidate
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    public synchronized StringBuffer append(int i) {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   431
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        super.append(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   439
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    public synchronized StringBuffer appendCodePoint(int codePoint) {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   441
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        super.appendCodePoint(codePoint);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   446
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    public synchronized StringBuffer append(long lng) {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   448
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        super.append(lng);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   453
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    public synchronized StringBuffer append(float f) {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   455
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        super.append(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   460
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    public synchronized StringBuffer append(double d) {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   462
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        super.append(d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * @throws StringIndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * @since      1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   471
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    public synchronized StringBuffer delete(int start, int end) {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   473
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        super.delete(start, end);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * @throws StringIndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * @since      1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   482
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    public synchronized StringBuffer deleteCharAt(int index) {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   484
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        super.deleteCharAt(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * @throws StringIndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * @since      1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   493
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    public synchronized StringBuffer replace(int start, int end, String str) {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   495
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        super.replace(start, end, str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * @throws StringIndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * @since      1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   504
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    public synchronized String substring(int start) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        return substring(start, count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * @throws IndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     * @since      1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   513
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    public synchronized CharSequence subSequence(int start, int end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        return super.substring(start, end);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * @throws StringIndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     * @since      1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   522
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    public synchronized String substring(int start, int end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
        return super.substring(start, end);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * @throws StringIndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * @since      1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   531
    @Override
1223
5c1037124466 6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents: 2
diff changeset
   532
    public synchronized StringBuffer insert(int index, char[] str, int offset,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
                                            int len)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   535
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        super.insert(index, str, offset, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     * @throws StringIndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   543
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    public synchronized StringBuffer insert(int offset, Object obj) {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   545
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        super.insert(offset, String.valueOf(obj));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * @throws StringIndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   553
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    public synchronized StringBuffer insert(int offset, String str) {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   555
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        super.insert(offset, str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * @throws StringIndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   563
    @Override
1223
5c1037124466 6728229: (str) StringBuilder.append(CharSequence) does not throw IndexOutOfBoundsException
martin
parents: 2
diff changeset
   564
    public synchronized StringBuffer insert(int offset, char[] str) {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   565
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        super.insert(offset, str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * @throws IndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * @since      1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   574
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    public StringBuffer insert(int dstOffset, CharSequence s) {
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   576
        // Note, synchronization achieved via invocations of other StringBuffer methods
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   577
        // after narrowing of s to specific type
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   578
        // Ditto for toStringCache clearing
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   579
        super.insert(dstOffset, s);
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   580
        return this;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     * @throws IndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * @since      1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   587
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    public synchronized StringBuffer insert(int dstOffset, CharSequence s,
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   589
            int start, int end)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
    {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   591
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        super.insert(dstOffset, s, start, end);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     * @throws StringIndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   599
    @Override
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   600
    public  StringBuffer insert(int offset, boolean b) {
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   601
        // Note, synchronization achieved via invocation of StringBuffer insert(int, String)
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   602
        // after conversion of b to String by super class method
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   603
        // Ditto for toStringCache clearing
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   604
        super.insert(offset, b);
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   605
        return this;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     * @throws IndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   611
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    public synchronized StringBuffer insert(int offset, char c) {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   613
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        super.insert(offset, c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     * @throws StringIndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   621
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
    public StringBuffer insert(int offset, int i) {
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   623
        // Note, synchronization achieved via invocation of StringBuffer insert(int, String)
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   624
        // after conversion of i to String by super class method
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   625
        // Ditto for toStringCache clearing
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   626
        super.insert(offset, i);
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   627
        return this;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     * @throws StringIndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   633
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
    public StringBuffer insert(int offset, long l) {
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   635
        // Note, synchronization achieved via invocation of StringBuffer insert(int, String)
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   636
        // after conversion of l to String by super class method
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   637
        // Ditto for toStringCache clearing
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   638
        super.insert(offset, l);
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   639
        return this;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     * @throws StringIndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   645
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    public StringBuffer insert(int offset, float f) {
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   647
        // Note, synchronization achieved via invocation of StringBuffer insert(int, String)
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   648
        // after conversion of f to String by super class method
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   649
        // Ditto for toStringCache clearing
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   650
        super.insert(offset, f);
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   651
        return this;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     * @throws StringIndexOutOfBoundsException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   657
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    public StringBuffer insert(int offset, double d) {
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   659
        // Note, synchronization achieved via invocation of StringBuffer insert(int, String)
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   660
        // after conversion of d to String by super class method
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   661
        // Ditto for toStringCache clearing
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   662
        super.insert(offset, d);
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   663
        return this;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     * @since      1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   669
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    public int indexOf(String str) {
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   671
        // Note, synchronization achieved via invocations of other StringBuffer methods
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   672
        return super.indexOf(str);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     * @since      1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   678
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    public synchronized int indexOf(String str, int fromIndex) {
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   680
        return super.indexOf(str, fromIndex);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     * @since      1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   686
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
    public int lastIndexOf(String str) {
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   688
        // Note, synchronization achieved via invocations of other StringBuffer methods
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        return lastIndexOf(str, count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     * @since      1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   695
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    public synchronized int lastIndexOf(String str, int fromIndex) {
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   697
        return super.lastIndexOf(str, fromIndex);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
    /**
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 17709
diff changeset
   701
     * @since   1.0.2
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     */
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   703
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
    public synchronized StringBuffer reverse() {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   705
        toStringCache = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
        super.reverse();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
14332
451c5dd717dc 6206780: (str) Forwarding append methods in String{Buffer,Builder} are inconsistent
jgish
parents: 13155
diff changeset
   710
    @Override
31671
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 29974
diff changeset
   711
    @HotSpotIntrinsicCandidate
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
    public synchronized String toString() {
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   713
        if (toStringCache == null) {
33663
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 31671
diff changeset
   714
            return toStringCache =
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 31671
diff changeset
   715
                    isLatin1() ? StringLatin1.newString(value, 0, count)
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 31671
diff changeset
   716
                               : StringUTF16.newString(value, 0, count);
17472
4ce9bd9f56ac 8013395: StringBuffer.toString performance regression impacting embedded benchmarks
dholmes
parents: 15312
diff changeset
   717
        }
33663
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 31671
diff changeset
   718
        return new String(toStringCache);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     * Serializable fields for StringBuffer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     * @serialField value  char[]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     *              The backing character array of this StringBuffer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     * @serialField count int
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
     *              The number of characters in this StringBuffer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     * @serialField shared  boolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
     *              A flag indicating whether the backing array is shared.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     *              The value is ignored upon deserialization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
    private static final java.io.ObjectStreamField[] serialPersistentFields =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        new java.io.ObjectStreamField("value", char[].class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        new java.io.ObjectStreamField("count", Integer.TYPE),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
        new java.io.ObjectStreamField("shared", Boolean.TYPE),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     * readObject is called to restore the state of the StringBuffer from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
     * a stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    private synchronized void writeObject(java.io.ObjectOutputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
        throws java.io.IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
        java.io.ObjectOutputStream.PutField fields = s.putFields();
33663
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 31671
diff changeset
   746
        char[] val = new char[capacity()];
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 31671
diff changeset
   747
        if (isLatin1()) {
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 31671
diff changeset
   748
            StringLatin1.getChars(value, 0, count, val, 0);
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 31671
diff changeset
   749
        } else {
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 31671
diff changeset
   750
            StringUTF16.getChars(value, 0, count, val, 0);
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 31671
diff changeset
   751
        }
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 31671
diff changeset
   752
        fields.put("value", val);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        fields.put("count", count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
        fields.put("shared", false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
        s.writeFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
     * readObject is called to restore the state of the StringBuffer from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
     * a stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
    private void readObject(java.io.ObjectInputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
        throws java.io.IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
        java.io.ObjectInputStream.GetField fields = s.readFields();
33663
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 31671
diff changeset
   765
        char[] val = (char[])fields.get("value", null);
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 31671
diff changeset
   766
        initBytes(val, 0, val.length);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        count = fields.get("count", 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
    }
33663
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 31671
diff changeset
   769
34326
2bb3b3aea3c5 8143553: StringBuffer.getByte(byte[], int, byte) should be package private (not protected)
sherman
parents: 33663
diff changeset
   770
    synchronized void getBytes(byte dst[], int dstBegin, byte coder) {
33663
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 31671
diff changeset
   771
        super.getBytes(dst, dstBegin, coder);
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 31671
diff changeset
   772
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
}