< 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


1724             StringUTF16.putCharsSB(this.value, count, s, off, end);
1725         }
1726         count += end - off;
1727     }
1728 
1729     /* IndexOutOfBoundsException, if out of bounds */
1730     private static void checkRange(int start, int end, int len) {
1731         if (start < 0 || start > end || end > len) {
1732             throw new IndexOutOfBoundsException(
1733                 "start " + start + ", end " + end + ", length " + len);
1734         }
1735     }
1736 
1737     /* StringIndexOutOfBoundsException, if out of bounds */
1738     private static void checkRangeSIOOBE(int start, int end, int len) {
1739         if (start < 0 || start > end || end > len) {
1740             throw new StringIndexOutOfBoundsException(
1741                 "start " + start + ", end " + end + ", length " + len);
1742         }
1743     }

















1744 }


1724             StringUTF16.putCharsSB(this.value, count, s, off, end);
1725         }
1726         count += end - off;
1727     }
1728 
1729     /* IndexOutOfBoundsException, if out of bounds */
1730     private static void checkRange(int start, int end, int len) {
1731         if (start < 0 || start > end || end > len) {
1732             throw new IndexOutOfBoundsException(
1733                 "start " + start + ", end " + end + ", length " + len);
1734         }
1735     }
1736 
1737     /* StringIndexOutOfBoundsException, if out of bounds */
1738     private static void checkRangeSIOOBE(int start, int end, int len) {
1739         if (start < 0 || start > end || end > len) {
1740             throw new StringIndexOutOfBoundsException(
1741                 "start " + start + ", end " + end + ", length " + len);
1742         }
1743     }
1744 
1745     /**
1746      * Determine the "coder" of the given CharSequence
1747      */
1748     static byte getCharSequenceCoder(CharSequence seq) {
1749         byte coder;
1750         if (seq instanceof String) {
1751             coder = ((String)seq).coder();
1752         } else if (seq instanceof AbstractStringBuilder) {
1753             coder = ((AbstractStringBuilder)seq).getCoder();
1754         } else if (COMPACT_STRINGS) {
1755             coder = LATIN1;
1756         } else {
1757             coder = UTF16;
1758         }
1759         return coder;
1760     }
1761 }
< prev index next >