--- old/src/java.base/share/classes/java/lang/StringUTF16.java 2018-02-27 09:54:26.050182610 -0800 +++ new/src/java.base/share/classes/java/lang/StringUTF16.java 2018-02-27 09:54:25.266105933 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -273,6 +273,20 @@ public static int compareTo(byte[] value, byte[] other) { int len1 = length(value); int len2 = length(other); + return compareValues(value, other, len1, len2); + } + + /* + * Checks the boundary and then compares the byte arrays. + */ + public static int compareTo(byte[] value, byte[] other, int len1, int len2) { + checkOffset(len1, value); + checkOffset(len2, other); + + return compareValues(value, other, len1, len2); + } + + private static int compareValues(byte[] value, byte[] other, int len1, int len2) { int lim = Math.min(len1, len2); for (int k = 0; k < lim; k++) { char c1 = getChar(value, k); @@ -289,6 +303,10 @@ return -StringLatin1.compareToUTF16(other, value); } + public static int compareToLatin1(byte[] value, byte[] other, int len1, int len2) { + return -StringLatin1.compareToUTF16(other, value, len2, len1); + } + public static int compareToCI(byte[] value, byte[] other) { int len1 = length(value); int len2 = length(other);