# HG changeset patch # User sherman # Date 1467061044 25200 # Node ID 0907704a240994c6c346f2608528fa22385871ec # Parent 3aa52182b3ad7c5b3a61cf05a59dd07e4c5884e5 8160312: ArrayIndexOutOfBoundsException when comparing strings case insensitive Reviewed-by: rriggs diff -r 3aa52182b3ad -r 0907704a2409 jdk/src/java.base/share/classes/java/lang/StringLatin1.java --- a/jdk/src/java.base/share/classes/java/lang/StringLatin1.java Wed Jul 05 21:53:18 2017 +0200 +++ b/jdk/src/java.base/share/classes/java/lang/StringLatin1.java Mon Jun 27 13:57:24 2016 -0700 @@ -137,8 +137,8 @@ char c1 = (char) CharacterDataLatin1.instance.toUpperCase(getChar(value, k)); char c2 = (char) CharacterDataLatin1.instance.toUpperCase(getChar(other, k)); if (c1 != c2) { - c1 = (char) CharacterDataLatin1.instance.toLowerCase(c1); - c2 = (char) CharacterDataLatin1.instance.toLowerCase(c2); + c1 = Character.toLowerCase(c1); + c2 = Character.toLowerCase(c2); if (c1 != c2) { return c1 - c2; } diff -r 3aa52182b3ad -r 0907704a2409 jdk/test/java/lang/String/CompareIC.java --- a/jdk/test/java/lang/String/CompareIC.java Wed Jul 05 21:53:18 2017 +0200 +++ b/jdk/test/java/lang/String/CompareIC.java Mon Jun 27 13:57:24 2016 -0700 @@ -23,7 +23,7 @@ /* * @test - * @bug 4124769 + * @bug 4124769 8160312 * @summary Test ignore-case comparison * */ @@ -45,6 +45,10 @@ comparer.testTriplet(test1, test2, test3); test2 = test2.toLowerCase(); comparer.testTriplet(test1, test2, test3); + + // toLowerCase -> non-latin1 + if ("\u00b5".compareToIgnoreCase("X") < 0) + throw new RuntimeException("Comparison failure1"); } private void testTriplet(String one, String two, String three)