< prev index next >

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

Print this page
rev 54260 : 8221430: StringBuffer(CharSequence) constructor truncates when -XX:-CompactStrings specified

*** 1739,1744 **** --- 1739,1761 ---- if (start < 0 || start > end || end > len) { throw new StringIndexOutOfBoundsException( "start " + start + ", end " + end + ", length " + len); } } + + /** + * Determine the "coder" of the given CharSequence + */ + static byte getCharSequenceCoder(CharSequence seq) { + byte coder; + if (seq instanceof String) { + coder = ((String)seq).coder(); + } else if (seq instanceof AbstractStringBuilder) { + coder = ((AbstractStringBuilder)seq).getCoder(); + } else if (COMPACT_STRINGS) { + coder = LATIN1; + } else { + coder = UTF16; + } + return coder; + } }
< prev index next >