Skip to content

Commit fc37c50

Browse files
committed
Replace String.charAt with StringBuilder.charAt
1 parent 72cd512 commit fc37c50

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

test/hotspot/jtreg/compiler/c2/aarch64/TestTrampoline.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,19 @@ private static void checkOutput(OutputAnalyzer output) {
8989
}
9090

9191
static class Test {
92-
private static void test(String s, int i) {
92+
// Use a StringBuilder to avoid issues with String.charAt() not being
93+
// inlined on Windows because its UTF-16 path was executed at startup
94+
// but not enough for C2 to inline it.
95+
private static void test(StringBuilder s, int i) {
9396
if (s.charAt(i) > 128)
9497
throw new RuntimeException();
9598
}
9699

97100
public static void main(String[] args) {
98-
String s = "Returns the char value at the specified index.";
101+
var sb = new StringBuilder();
102+
sb.append("Returns the char value at the specified index.");
99103
for (int i = 0; i < ITERATIONS_TO_HEAT_LOOP; ++i) {
100-
test(s, i % s.length());
104+
test(sb, i % sb.length());
101105
}
102106
}
103107
}

0 commit comments

Comments
 (0)