< prev index next >

src/java.base/share/classes/java/lang/StringBuffer.java

Print this page
rev 13124 : [mq]: XXXXXXX-ASB-shared-value

*** 98,113 **** public final class StringBuffer extends AbstractStringBuilder implements java.io.Serializable, CharSequence { - /** - * A cache of the last value returned by toString. Cleared - * whenever the StringBuffer is modified. - */ - private transient String toStringCache; - /** use serialVersionUID from JDK 1.0.2 for interoperability */ static final long serialVersionUID = 3388685877147921107L; /** * Constructs a string buffer with no characters in it and an --- 98,107 ----
*** 190,200 **** * @throws IndexOutOfBoundsException {@inheritDoc} * @see #length() */ @Override public synchronized void setLength(int newLength) { - toStringCache = null; super.setLength(newLength); } /** * @throws IndexOutOfBoundsException {@inheritDoc} --- 184,193 ----
*** 255,279 **** * @throws IndexOutOfBoundsException {@inheritDoc} * @see #length() */ @Override public synchronized void setCharAt(int index, char ch) { - toStringCache = null; super.setCharAt(index, ch); } @Override public synchronized StringBuffer append(Object obj) { - toStringCache = null; super.append(String.valueOf(obj)); return this; } @Override @HotSpotIntrinsicCandidate public synchronized StringBuffer append(String str) { - toStringCache = null; super.append(str); return this; } /** --- 248,269 ----
*** 299,319 **** * @param sb the {@code StringBuffer} to append. * @return a reference to this object. * @since 1.4 */ public synchronized StringBuffer append(StringBuffer sb) { - toStringCache = null; super.append(sb); return this; } /** * @since 1.8 */ @Override synchronized StringBuffer append(AbstractStringBuilder asb) { - toStringCache = null; super.append(asb); return this; } /** --- 289,307 ----
*** 337,347 **** * @return a reference to this object. * @since 1.5 */ @Override public synchronized StringBuffer append(CharSequence s) { - toStringCache = null; super.append(s); return this; } /** --- 325,334 ----
*** 349,463 **** * @since 1.5 */ @Override public synchronized StringBuffer append(CharSequence s, int start, int end) { - toStringCache = null; super.append(s, start, end); return this; } @Override public synchronized StringBuffer append(char[] str) { - toStringCache = null; super.append(str); return this; } /** * @throws IndexOutOfBoundsException {@inheritDoc} */ @Override public synchronized StringBuffer append(char[] str, int offset, int len) { - toStringCache = null; super.append(str, offset, len); return this; } @Override public synchronized StringBuffer append(boolean b) { - toStringCache = null; super.append(b); return this; } @Override @HotSpotIntrinsicCandidate public synchronized StringBuffer append(char c) { - toStringCache = null; super.append(c); return this; } @Override @HotSpotIntrinsicCandidate public synchronized StringBuffer append(int i) { - toStringCache = null; super.append(i); return this; } /** * @since 1.5 */ @Override public synchronized StringBuffer appendCodePoint(int codePoint) { - toStringCache = null; super.appendCodePoint(codePoint); return this; } @Override public synchronized StringBuffer append(long lng) { - toStringCache = null; super.append(lng); return this; } @Override public synchronized StringBuffer append(float f) { - toStringCache = null; super.append(f); return this; } @Override public synchronized StringBuffer append(double d) { - toStringCache = null; super.append(d); return this; } /** * @throws StringIndexOutOfBoundsException {@inheritDoc} * @since 1.2 */ @Override public synchronized StringBuffer delete(int start, int end) { - toStringCache = null; super.delete(start, end); return this; } /** * @throws StringIndexOutOfBoundsException {@inheritDoc} * @since 1.2 */ @Override public synchronized StringBuffer deleteCharAt(int index) { - toStringCache = null; super.deleteCharAt(index); return this; } /** * @throws StringIndexOutOfBoundsException {@inheritDoc} * @since 1.2 */ @Override public synchronized StringBuffer replace(int start, int end, String str) { - toStringCache = null; super.replace(start, end, str); return this; } /** --- 336,437 ----
*** 493,533 **** */ @Override public synchronized StringBuffer insert(int index, char[] str, int offset, int len) { - toStringCache = null; super.insert(index, str, offset, len); return this; } /** * @throws StringIndexOutOfBoundsException {@inheritDoc} */ @Override public synchronized StringBuffer insert(int offset, Object obj) { - toStringCache = null; super.insert(offset, String.valueOf(obj)); return this; } /** * @throws StringIndexOutOfBoundsException {@inheritDoc} */ @Override public synchronized StringBuffer insert(int offset, String str) { - toStringCache = null; super.insert(offset, str); return this; } /** * @throws StringIndexOutOfBoundsException {@inheritDoc} */ @Override public synchronized StringBuffer insert(int offset, char[] str) { - toStringCache = null; super.insert(offset, str); return this; } /** --- 467,503 ----
*** 536,546 **** */ @Override public StringBuffer insert(int dstOffset, CharSequence s) { // Note, synchronization achieved via invocations of other StringBuffer methods // after narrowing of s to specific type - // Ditto for toStringCache clearing super.insert(dstOffset, s); return this; } /** --- 506,515 ----
*** 549,559 **** */ @Override public synchronized StringBuffer insert(int dstOffset, CharSequence s, int start, int end) { - toStringCache = null; super.insert(dstOffset, s, start, end); return this; } /** --- 518,527 ----
*** 561,581 **** */ @Override public StringBuffer insert(int offset, boolean b) { // Note, synchronization achieved via invocation of StringBuffer insert(int, String) // after conversion of b to String by super class method - // Ditto for toStringCache clearing super.insert(offset, b); return this; } /** * @throws IndexOutOfBoundsException {@inheritDoc} */ @Override public synchronized StringBuffer insert(int offset, char c) { - toStringCache = null; super.insert(offset, c); return this; } /** --- 529,547 ----
*** 583,593 **** */ @Override public StringBuffer insert(int offset, int i) { // Note, synchronization achieved via invocation of StringBuffer insert(int, String) // after conversion of i to String by super class method - // Ditto for toStringCache clearing super.insert(offset, i); return this; } /** --- 549,558 ----
*** 595,605 **** */ @Override public StringBuffer insert(int offset, long l) { // Note, synchronization achieved via invocation of StringBuffer insert(int, String) // after conversion of l to String by super class method - // Ditto for toStringCache clearing super.insert(offset, l); return this; } /** --- 560,569 ----
*** 607,617 **** */ @Override public StringBuffer insert(int offset, float f) { // Note, synchronization achieved via invocation of StringBuffer insert(int, String) // after conversion of f to String by super class method - // Ditto for toStringCache clearing super.insert(offset, f); return this; } /** --- 571,580 ----
*** 619,629 **** */ @Override public StringBuffer insert(int offset, double d) { // Note, synchronization achieved via invocation of StringBuffer insert(int, String) // after conversion of d to String by super class method - // Ditto for toStringCache clearing super.insert(offset, d); return this; } /** --- 582,591 ----
*** 663,686 **** /** * @since 1.0.2 */ @Override public synchronized StringBuffer reverse() { - toStringCache = null; super.reverse(); return this; } @Override @HotSpotIntrinsicCandidate public synchronized String toString() { ! if (toStringCache == null) { ! return toStringCache = ! isLatin1() ? StringLatin1.newString(value, 0, count) ! : StringUTF16.newString(value, 0, count); } ! return new String(toStringCache); } /** * Serializable fields for StringBuffer. * --- 625,650 ---- /** * @since 1.0.2 */ @Override public synchronized StringBuffer reverse() { super.reverse(); return this; } @Override @HotSpotIntrinsicCandidate public synchronized String toString() { ! final byte[] value = this.value; ! if (isLatin1()) { ! if ((count << coder) < value.length) { ! return StringLatin1.newString(value, 0, count); ! } ! shared = true; ! return new String(value, String.LATIN1); } ! return StringUTF16.newString(value, 0, count); } /** * Serializable fields for StringBuffer. *
*** 726,735 **** --- 690,700 ---- throws java.io.IOException, ClassNotFoundException { java.io.ObjectInputStream.GetField fields = s.readFields(); char[] val = (char[])fields.get("value", null); initBytes(val, 0, val.length); count = fields.get("count", 0); + shared = false; } synchronized void getBytes(byte dst[], int dstBegin, byte coder) { super.getBytes(dst, dstBegin, coder); }
< prev index next >