--- old/src/java.base/share/classes/java/lang/String.java 2017-03-22 15:53:01.000000000 +0300 +++ new/src/java.base/share/classes/java/lang/String.java 2017-03-22 15:53:01.000000000 +0300 @@ -1121,6 +1121,8 @@ } } } else { + // Redundant: n == length() (see earlier check) + checkOffset(n, val.length >> 1); for (int i = 0; i < n; i++) { if (StringUTF16.getChar(val, i) != cs.charAt(i)) { return false; @@ -1834,7 +1836,19 @@ int i = min + fromIndex; int strLastIndex = tgtCount - 1; - char strLastChar = (char)(tgt[strLastIndex] & 0xff); + char strLastChar = (char) (tgt[strLastIndex] & 0xff); + + // Redundant: + // i == min + fromIndex + // fromIndex <= rightIndex (earlier check) ==> + // i <= min + rightIndex == (tgtCount - 1) + (srcCount - tgtCount) == srcCount - 1 ==> + // i <= srcCount - 1 + // + // And (srcCount < src.length >> 1) is covered by: + // ASB.lastIndexOf(String str, int fromIndex) { + // checkIndex(count, value.length >> coder); + checkIndex(i, src.length >> 1); + startSearchForLastChar: while (true) { while (i >= min && StringUTF16.getChar(src, i) != strLastChar) {