< prev index next >
src/java.base/share/classes/java/lang/AbstractStringBuilder.java
Print this page
rev 54280 : 8221430: StringBuffer(CharSequence) constructor truncates when -XX:-CompactStrings specified
*** 94,112 ****
/**
* Creates an AbstractStringBuilder with the specified coder and with
* the initial capacity equal to the smaller of (length + addition)
* and Integer.MAX_VALUE.
*/
! AbstractStringBuilder(byte coder, int length, int addition) {
if (length < 0) {
throw new NegativeArraySizeException("Negative length: " + length);
}
- this.coder = coder;
int capacity = (length < Integer.MAX_VALUE - addition)
? length + addition : Integer.MAX_VALUE;
! value = (coder == LATIN1)
! ? new byte[capacity] : StringUTF16.newBytesFor(capacity);
}
/**
* Compares the objects of two AbstractStringBuilder implementations lexicographically.
*
--- 94,116 ----
/**
* Creates an AbstractStringBuilder with the specified coder and with
* the initial capacity equal to the smaller of (length + addition)
* and Integer.MAX_VALUE.
*/
! AbstractStringBuilder(byte coderHint, int length, int addition) {
if (length < 0) {
throw new NegativeArraySizeException("Negative length: " + length);
}
int capacity = (length < Integer.MAX_VALUE - addition)
? length + addition : Integer.MAX_VALUE;
! if (COMPACT_STRINGS && coderHint == LATIN1) {
! value = new byte[capacity];
! coder = LATIN1;
! } else {
! value = StringUTF16.newBytesFor(capacity);
! coder = UTF16;
! }
}
/**
* Compares the objects of two AbstractStringBuilder implementations lexicographically.
*
< prev index next >