--- a/jdk/src/java.base/share/classes/java/lang/StringUTF16.java Mon Nov 23 11:07:36 2015 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/StringUTF16.java Fri Nov 27 09:37:33 2015 +0100
@@ -35,6 +35,7 @@
import static java.lang.String.LATIN1;
import static java.lang.String.checkIndex;
import static java.lang.String.checkOffset;
+import static java.lang.String.checkBoundsOffCount;
final class StringUTF16 {
@@ -156,6 +157,8 @@
// compressedCopy byte[] -> byte[]
@HotSpotIntrinsicCandidate
public static int compress(byte[] src, int srcOff, byte[] dst, int dstOff, int len) {
+ // We need a range check here because 'getChar' has no checks
+ checkBoundsOffCount(srcOff, len, src.length);
for (int i = 0; i < len; i++) {
int c = getChar(src, srcOff++);
if (c >>> 8 != 0) {
@@ -200,6 +203,8 @@
@HotSpotIntrinsicCandidate
public static void getChars(byte[] value, int srcBegin, int srcEnd, char dst[], int dstBegin) {
+ // We need a range check here because 'getChar' has no checks
+ checkBoundsOffCount(srcBegin, srcEnd - srcBegin, value.length);
for (int i = srcBegin; i < srcEnd; i++) {
dst[dstBegin++] = getChar(value, i);
}
@@ -909,11 +914,6 @@
////////////////////////////////////////////////////////////////
- public static void getCharsSB(byte[] val, int srcBegin, int srcEnd, char dst[], int dstBegin) {
- checkOffset(srcEnd, val.length >> 1);
- getChars(val, srcBegin, srcEnd, dst, dstBegin);
- }
-
public static void putCharSB(byte[] val, int index, int c) {
checkIndex(index, val.length >> 1);
putChar(val, index, c);
@@ -946,11 +946,6 @@
return codePointCount(val, beginIndex, endIndex);
}
- public static String newStringSB(byte[] val, int index, int len) {
- checkOffset(index + len, val.length >> 1);
- return newString(val, index, len);
- }
-
////////////////////////////////////////////////////////////////
private static native boolean isBigEndian();