Fix compressible string check for ctors with `hibyte`.
Only the low 8 bits of the `hibyte` are relevant but we
were checking the whole `hibyte`, erroneously creating
an uncompressed string when the low bits are zero but
high bits are non-zero. String.equals() depends on all
compressible Strings being actually compressed.
Test: Added regression test to 021-string2.
Test: m test-art-host-gtest
Test: testrunner.py --host
Bug: 31040547
Bug: 63661357
Change-Id: I31690b544de928ce9c6f39f3d144d3e2029f38f6
diff --git a/test/021-string2/src/Main.java b/test/021-string2/src/Main.java
index 194f4a1..3b81d8e 100644
--- a/test/021-string2/src/Main.java
+++ b/test/021-string2/src/Main.java
@@ -700,6 +700,11 @@
$noinline$constNonAsciiString35Equals("\u0440123456789012345678901234567890123x"));
Assert.assertFalse(
$noinline$constNonAsciiString35Equals("01234567890123456789012345678901234"));
+
+ // Regression test for incorrectly creating an uncompressed string when the
+ // string should be compressed. Only the low 8 bits are relevant but the whole
+ // `hibyte` was erroneously tested. Bug: 63661357
+ Assert.assertTrue("A".equals(new String(new byte[] { (byte)'A' }, /* hibyte */ 0x100)));
}
public static boolean $noinline$equalsConstString0(String s) {