8264544: Case-insensitive comparison issue with supplementary characters.

Co-authored-by: Chris Johnson <chriswjohnson.jdk@gmail.com>
Reviewed-by: joehw, iris, alanb
This commit is contained in:
Naoto Sato 2021-04-02 16:32:45 +00:00
parent f60e81bf7b
commit 6c145c4768
3 changed files with 11 additions and 8 deletions

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -342,12 +342,12 @@ final class StringUTF16 {
cp1 = codePointIncluding(value, cp1, k1, toffset, tlast); cp1 = codePointIncluding(value, cp1, k1, toffset, tlast);
if (cp1 < 0) { if (cp1 < 0) {
k1++; k1++;
cp1 -= cp1; cp1 = -cp1;
} }
cp2 = codePointIncluding(other, cp2, k2, ooffset, olast); cp2 = codePointIncluding(other, cp2, k2, ooffset, olast);
if (cp2 < 0) { if (cp2 < 0) {
k2++; k2++;
cp2 -= cp2; cp2 = -cp2;
} }
int diff = compareCodePointCI(cp1, cp2); int diff = compareCodePointCI(cp1, cp2);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -28,7 +28,7 @@ import static org.testng.Assert.assertEquals;
/* /*
* @test * @test
* @bug 8077559 8248655 * @bug 8077559 8248655 8264544
* @summary Tests Compact String. This one is for String.compareToIgnoreCase. * @summary Tests Compact String. This one is for String.compareToIgnoreCase.
* @run testng/othervm -XX:+CompactStrings CompareToIgnoreCase * @run testng/othervm -XX:+CompactStrings CompareToIgnoreCase
* @run testng/othervm -XX:-CompactStrings CompareToIgnoreCase * @run testng/othervm -XX:-CompactStrings CompareToIgnoreCase
@ -69,6 +69,7 @@ public class CompareToIgnoreCase extends CompactString {
new Object[] { STRING_M11, "a\uFF42", -1 }, new Object[] { STRING_M11, "a\uFF42", -1 },
new Object[] { STRING_SUPPLEMENTARY, STRING_SUPPLEMENTARY_LOWERCASE, 0 }, new Object[] { STRING_SUPPLEMENTARY, STRING_SUPPLEMENTARY_LOWERCASE, 0 },
new Object[] { STRING_SUPPLEMENTARY, "\uD801\uDC28\uD801\uDC27\uFF41a", -38 }, new Object[] { STRING_SUPPLEMENTARY, "\uD801\uDC28\uD801\uDC27\uFF41a", -38 },
new Object[] { STRING_SUPPLEMENTARY, "\uD802\uDC00\uD801\uDC01\uFF21A", -984 },
}; };
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -28,7 +28,7 @@ import static org.testng.Assert.assertEquals;
/* /*
* @test * @test
* @bug 8077559 8248655 * @bug 8077559 8248655 8264544
* @summary Tests Compact String. This one is for String.regionMatches. * @summary Tests Compact String. This one is for String.regionMatches.
* @run testng/othervm -XX:+CompactStrings RegionMatches * @run testng/othervm -XX:+CompactStrings RegionMatches
* @run testng/othervm -XX:-CompactStrings RegionMatches * @run testng/othervm -XX:-CompactStrings RegionMatches
@ -75,6 +75,7 @@ public class RegionMatches extends CompactString {
new Object[] { STRING_SUPPLEMENTARY, true, 4, "\uFF21", 0, 1, new Object[] { STRING_SUPPLEMENTARY, true, 4, "\uFF21", 0, 1,
true }, true },
new Object[] { STRING_SUPPLEMENTARY, true, 5, "A", 0, 1, true }, new Object[] { STRING_SUPPLEMENTARY, true, 5, "A", 0, 1, true },
new Object[] { STRING_SUPPLEMENTARY, true, 0, "\uD802\uDC00\uD801\uDC01\uFF21A", 0, 2, false },
new Object[] { STRING_SUPPLEMENTARY_LOWERCASE, false, 0, new Object[] { STRING_SUPPLEMENTARY_LOWERCASE, false, 0,
"\uD801\uDC28\uD801\uDC29", 0, 4, true }, "\uD801\uDC28\uD801\uDC29", 0, 4, true },
new Object[] { STRING_SUPPLEMENTARY_LOWERCASE, true, 0, new Object[] { STRING_SUPPLEMENTARY_LOWERCASE, true, 0,
@ -90,7 +91,8 @@ public class RegionMatches extends CompactString {
new Object[] { STRING_SUPPLEMENTARY_LOWERCASE, false, 4, new Object[] { STRING_SUPPLEMENTARY_LOWERCASE, false, 4,
"\uFF21", 0, 1, false }, "\uFF21", 0, 1, false },
new Object[] { STRING_SUPPLEMENTARY_LOWERCASE, false, 4, new Object[] { STRING_SUPPLEMENTARY_LOWERCASE, false, 4,
"\uFF41", 0, 1, true }, }; "\uFF41", 0, 1, true },
};
} }
@Test(dataProvider = "provider") @Test(dataProvider = "provider")