< prev index next >
src/java.base/share/classes/java/lang/StringUTF16.java
Print this page
@@ -34,10 +34,11 @@
import static java.lang.String.UTF16;
import static java.lang.String.LATIN1;
import static java.lang.String.checkIndex;
import static java.lang.String.checkOffset;
import static java.lang.String.checkBoundsOffCount;
+import static java.lang.String.checkBoundsBeginEnd;
final class StringUTF16 {
public static byte[] newBytesFor(int len) {
if (len < 0) {
@@ -411,10 +412,11 @@
}
}
return -1;
}
+ // srcCoder == UTF16 && tgtCoder == UTF16
public static int lastIndexOf(byte[] src, int srcCount,
byte[] tgt, int tgtCount, int fromIndex) {
int min = tgtCount - 1;
int i = min + fromIndex;
int strLastIndex = tgtCount - 1;
@@ -930,16 +932,16 @@
checkIndex(index, val.length >> 1);
putChar(val, index, c);
}
public static void putCharsSB(byte[] val, int index, char[] ca, int off, int end) {
- checkOffset(index + end - off, val.length >> 1);
+ checkBoundsOffCount(index, index + end - off, val.length >> 1);
putChars(val, index, ca, off, end);
}
public static void putCharsSB(byte[] val, int index, CharSequence s, int off, int end) {
- checkOffset(index + end - off, val.length >> 1);
+ checkBoundsOffCount(index, end - off, val.length >> 1);
for (int i = off; i < end; i++) {
putChar(val, index++, s.charAt(i));
}
}
@@ -952,11 +954,11 @@
checkOffset(index, val.length >> 1);
return codePointBefore(val, index);
}
public static int codePointCountSB(byte[] val, int beginIndex, int endIndex) {
- checkOffset(endIndex, val.length >> 1);
+ checkBoundsBeginEnd(beginIndex, endIndex, val.length >> 1);
return codePointCount(val, beginIndex, endIndex);
}
////////////////////////////////////////////////////////////////
< prev index next >