changeset 39301:0907704a2409

8160312: ArrayIndexOutOfBoundsException when comparing strings case insensitive Reviewed-by: rriggs
author sherman
date Mon, 27 Jun 2016 13:57:24 -0700
parents 3aa52182b3ad
children aa8d0bc2a6d2
files jdk/src/java.base/share/classes/java/lang/StringLatin1.java jdk/test/java/lang/String/CompareIC.java
diffstat 2 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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;
                     }
--- 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)