1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 import junit.framework.Assert;
18 import java.util.Locale;
19 
20 /**
21  * more string tests
22  */
23 public class Main {
main(String args[])24     public static void main(String args[]) {
25         String test = "0123456789";
26         String test1 = new String("0123456789");    // different object
27         String test2 = new String("0123456780");    // different value
28         String offset = new String("xxx0123456789yyy");
29         String sub = offset.substring(3, 13);
30         Object blah = new Object();
31 
32         Assert.assertTrue(test.equals(test));
33         Assert.assertTrue(test.equals(test1));
34         Assert.assertFalse(test.equals(test2));
35 
36         Assert.assertEquals(test.compareTo(test1), 0);
37         Assert.assertTrue(test1.compareTo(test2) > 0);
38         Assert.assertTrue(test2.compareTo(test1) < 0);
39 
40         Assert.assertEquals("".compareTo(""), 0);
41         Assert.assertTrue(test.compareTo("") > 0);
42         Assert.assertTrue("".compareTo(test) < 0);
43 
44         /* compare string with a nonzero offset, in left/right side */
45         Assert.assertEquals(test.compareTo(sub), 0);
46         Assert.assertEquals(sub.compareTo(test), 0);
47         Assert.assertTrue(test.equals(sub));
48         Assert.assertTrue(sub.equals(test));
49         /* same base, one is a substring */
50         Assert.assertFalse(offset.equals(sub));
51         Assert.assertFalse(sub.equals(offset));
52         /* wrong class */
53         Assert.assertFalse(test.equals(blah));
54 
55         /* null ptr - throw */
56         try {
57             test.compareTo(null);
58             Assert.fail("didn't get expected npe");
59         } catch (NullPointerException npe) {
60             System.out.println("Got expected npe");
61         }
62         /* null ptr - ok */
63         Assert.assertFalse(test.equals(null));
64 
65         test = test.substring(1);
66         Assert.assertTrue(test.equals("123456789"));
67         Assert.assertFalse(test.equals(test1));
68 
69         test = test.substring(1);
70         Assert.assertTrue(test.equals("23456789"));
71 
72         test = test.substring(1);
73         Assert.assertTrue(test.equals("3456789"));
74 
75         test = test.substring(1);
76         Assert.assertTrue(test.equals("456789"));
77 
78         test = test.substring(3,5);
79         Assert.assertTrue(test.equals("78"));
80 
81         test = "this/is/a/path";
82         String[] strings = test.split("/");
83         Assert.assertEquals(4, strings.length);
84 
85         Assert.assertEquals("this is a path", test.replaceAll("/", " "));
86         Assert.assertEquals("this is a path", test.replace("/", " "));
87 
88         String result = new String(new char[] { 'O', 'K' });
89         System.out.println(result);
90 
91         testCompareToAndEquals();
92         testIndexOf();
93 
94         String s0_0 = "\u0000";
95         String s0_1 = new String(s0_0);
96         String s0_2 = new String(new char[] { '\u0000' });
97         String s0_3 = s0_0 + "";
98         System.out.println(
99             " " + $noinline$equals(s0_0, s0_0) +
100             " " + $noinline$equals(s0_0, s0_1) +
101             " " + $noinline$equals(s0_0, s0_2) +
102             " " + $noinline$equals(s0_0, s0_3));
103         System.out.println(
104             " " + $noinline$equals(s0_1, s0_0) +
105             " " + $noinline$equals(s0_1, s0_1) +
106             " " + $noinline$equals(s0_1, s0_2) +
107             " " + $noinline$equals(s0_1, s0_3));
108         System.out.println(
109             " " + $noinline$equals(s0_2, s0_0) +
110             " " + $noinline$equals(s0_2, s0_1) +
111             " " + $noinline$equals(s0_2, s0_2) +
112             " " + $noinline$equals(s0_2, s0_3));
113         System.out.println(
114             " " + $noinline$equals(s0_3, s0_0) +
115             " " + $noinline$equals(s0_3, s0_1) +
116             " " + $noinline$equals(s0_3, s0_2) +
117             " " + $noinline$equals(s0_3, s0_3));
118 
119         testEqualsConstString();
120         testConstStringEquals();
121 
122         // Regression tests for String.setCharAt() breaking string compression invariants.
123         Locale en_US = new Locale("en", "US");
124         Assert.assertEquals("I", /* Small latin dotless i */ "\u0131".toUpperCase());
125         Assert.assertEquals("abc", "a\u0131c".replace('\u0131', 'b'));
126         Assert.assertEquals("a\u0131c", "abc".replace('b', '\u0131'));
127 
128         // Regression test for scratch register exhaustion in String.equals() intrinsic on arm64.
129         Assert.assertFalse(result.equals("Very long constant string, so that the known constant count field cannot be embedded in a CMP immediate instruction on arm64. Since it can hold 12-bit values, optionally shifted left by 12, let's go somewhere over 2^12, i.e. 4096. That should trigger the bug with or without string compression. 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/"));
130     }
131 
testCompareToAndEquals()132     public static void testCompareToAndEquals() {
133         String[] strings = {
134                 // Special: empty string.
135                 "",
136                 // Category 0, ASCII strings:
137                 //     "0123456789abcdef".substring(0, index + 1)
138                 "0",
139                 "01",
140                 "012",
141                 "0123",
142                 "01234",
143                 "012345",
144                 "0123456",
145                 "01234567",
146                 "012345678",
147                 "0123456789",
148                 "0123456789a",
149                 "0123456789ab",
150                 "0123456789abc",
151                 "0123456789abcd",
152                 "0123456789abcde",
153                 "0123456789abcdef",
154                 // Category 1, ASCII strings:
155                 //     "0123456789abcdef".substring(0, index) + "x"
156                 "x",
157                 "0x",
158                 "01x",
159                 "012x",
160                 "0123x",
161                 "01234x",
162                 "012345x",
163                 "0123456x",
164                 "01234567x",
165                 "012345678x",
166                 "0123456789x",
167                 "0123456789ax",
168                 "0123456789abx",
169                 "0123456789abcx",
170                 "0123456789abcdx",
171                 "0123456789abcdex",
172                 // Category 2, ASCII strings,
173                 //     "0123456789abcdef".substring(0, index) + "x" +
174                 //     "0123456789abcdef".substring(index + 1)
175                 "x123456789abcdef",
176                 "0x23456789abcdef",
177                 "01x3456789abcdef",
178                 "012x456789abcdef",
179                 "0123x56789abcdef",
180                 "01234x6789abcdef",
181                 "012345x789abcdef",
182                 "0123456x89abcdef",
183                 "01234567x9abcdef",
184                 "012345678xabcdef",
185                 "0123456789xbcdef",
186                 "0123456789axcdef",
187                 "0123456789abxdef",
188                 "0123456789abcxef",
189                 "0123456789abcdxf",
190                 "0123456789abcdex",
191                 // Category 3, ASCII strings:
192                 //     "z" + "0123456789abcdef".substring(1, index + 1)
193                 "z",
194                 "z1",
195                 "z12",
196                 "z123",
197                 "z1234",
198                 "z12345",
199                 "z123456",
200                 "z1234567",
201                 "z12345678",
202                 "z123456789",
203                 "z123456789a",
204                 "z123456789ab",
205                 "z123456789abc",
206                 "z123456789abcd",
207                 "z123456789abcde",
208                 "z123456789abcdef",
209                 // Category 4, non-ASCII strings:
210                 //     "0123456789abcdef".substring(0, index) + "\u0440"
211                 "\u0440",
212                 "0\u0440",
213                 "01\u0440",
214                 "012\u0440",
215                 "0123\u0440",
216                 "01234\u0440",
217                 "012345\u0440",
218                 "0123456\u0440",
219                 "01234567\u0440",
220                 "012345678\u0440",
221                 "0123456789\u0440",
222                 "0123456789a\u0440",
223                 "0123456789ab\u0440",
224                 "0123456789abc\u0440",
225                 "0123456789abcd\u0440",
226                 "0123456789abcde\u0440",
227                 // Category 5, non-ASCII strings:
228                 //     "0123456789abcdef".substring(0, index) + "\u0440" +
229                 //     "0123456789abcdef".substring(index + 1)
230                 "\u0440123456789abcdef",
231                 "0\u044023456789abcdef",
232                 "01\u04403456789abcdef",
233                 "012\u0440456789abcdef",
234                 "0123\u044056789abcdef",
235                 "01234\u04406789abcdef",
236                 "012345\u0440789abcdef",
237                 "0123456\u044089abcdef",
238                 "01234567\u04409abcdef",
239                 "012345678\u0440abcdef",
240                 "0123456789\u0440bcdef",
241                 "0123456789a\u0440cdef",
242                 "0123456789ab\u0440def",
243                 "0123456789abc\u0440ef",
244                 "0123456789abcd\u0440f",
245                 "0123456789abcde\u0440",
246                 // Category 6, ASCII strings:
247                 //     "\u0443" + "0123456789abcdef".substring(1, index + 1)
248                 "\u0443",
249                 "\u04431",
250                 "\u044312",
251                 "\u0443123",
252                 "\u04431234",
253                 "\u044312345",
254                 "\u0443123456",
255                 "\u04431234567",
256                 "\u044312345678",
257                 "\u0443123456789",
258                 "\u0443123456789a",
259                 "\u0443123456789ab",
260                 "\u0443123456789abc",
261                 "\u0443123456789abcd",
262                 "\u0443123456789abcde",
263                 "\u0443123456789abcdef",
264                 // Category 7, non-ASCII strings:
265                 //     "0123456789abcdef".substring(0, index) + "\u0482"
266                 "\u0482",
267                 "0\u0482",
268                 "01\u0482",
269                 "012\u0482",
270                 "0123\u0482",
271                 "01234\u0482",
272                 "012345\u0482",
273                 "0123456\u0482",
274                 "01234567\u0482",
275                 "012345678\u0482",
276                 "0123456789\u0482",
277                 "0123456789a\u0482",
278                 "0123456789ab\u0482",
279                 "0123456789abc\u0482",
280                 "0123456789abcd\u0482",
281                 "0123456789abcde\u0482",
282                 // Category 8, non-ASCII strings:
283                 //     "0123456789abcdef".substring(0, index) + "\u0482" +
284                 //     "0123456789abcdef".substring(index + 1)
285                 "\u0482123456789abcdef",
286                 "0\u048223456789abcdef",
287                 "01\u04823456789abcdef",
288                 "012\u0482456789abcdef",
289                 "0123\u048256789abcdef",
290                 "01234\u04826789abcdef",
291                 "012345\u0482789abcdef",
292                 "0123456\u048289abcdef",
293                 "01234567\u04829abcdef",
294                 "012345678\u0482abcdef",
295                 "0123456789\u0482bcdef",
296                 "0123456789a\u0482cdef",
297                 "0123456789ab\u0482def",
298                 "0123456789abc\u0482ef",
299                 "0123456789abcd\u0482f",
300                 "0123456789abcde\u0482",
301                 // Category 9, ASCII strings:
302                 //     "\u0489" + "0123456789abcdef".substring(1, index + 1)
303                 "\u0489",
304                 "\u04891",
305                 "\u048912",
306                 "\u0489123",
307                 "\u04891234",
308                 "\u048912345",
309                 "\u0489123456",
310                 "\u04891234567",
311                 "\u048912345678",
312                 "\u0489123456789",
313                 "\u0489123456789a",
314                 "\u0489123456789ab",
315                 "\u0489123456789abc",
316                 "\u0489123456789abcd",
317                 "\u0489123456789abcde",
318                 "\u0489123456789abcdef",
319         };
320         int length = strings.length;
321         Assert.assertEquals(1 + 16 * 10, length);
322         for (int i = 0; i != length; ++i) {
323             String lhs = strings[i];
324             for (int j = 0; j != length; ++j) {
325                 String rhs = strings[j];
326                 int result = $noinline$compareTo(lhs, rhs);
327                 final int expected;
328                 if (i == 0 || j == 0 || i == j) {
329                     // One of the strings is empty or the strings are the same.
330                     expected = lhs.length() - rhs.length();
331                 } else {
332                     int i_category = (i - 1) / 16;
333                     int i_index = (i - 1) % 16;
334                     int j_category = (j - 1) / 16;
335                     int j_index = (j - 1) % 16;
336                     int min_ij_index = (i_index < j_index) ? i_index : j_index;
337                     if (i_category == j_category) {
338                         switch (i_category) {
339                             case 0: case 3: case 6: case 9:
340                                 // Differs in length.
341                                 expected = lhs.length() - rhs.length();
342                                 break;
343                             case 1: case 2: case 4: case 5: case 7: case 8:
344                                 // Differs in charAt(min_ij_index).
345                                 expected = lhs.charAt(min_ij_index) - rhs.charAt(min_ij_index);
346                                 break;
347                             default: throw new Error("Unexpected category.");
348                       }
349                     } else if (i_category == 3 || i_category == 6 || i_category == 9 ||
350                                j_category == 3 || j_category == 6 || j_category == 9) {
351                         // In these categories, charAt(0) differs from other categories' strings.
352                         expected = lhs.charAt(0) - rhs.charAt(0);
353                     } else if (// Category 0 string is a prefix to any longer string in
354                                // remaining categories.
355                                (i_category == 0 && i_index < j_index) ||
356                                (j_category == 0 && j_index < i_index) ||
357                                // Category 2 string is a prefix to category 3 string at the same
358                                // index. Similar for categories 4 and 5 and also 7 and 8.
359                                // This includes matching last strings of these pairs of categories.
360                                (i_index == j_index &&
361                                    ((i_category == 1 && j_category == 2) ||
362                                     (i_category == 2 && j_category == 1) ||
363                                     (i_category == 4 && j_category == 5) ||
364                                     (i_category == 5 && j_category == 4) ||
365                                     (i_category == 7 && j_category == 8) ||
366                                     (i_category == 8 && j_category == 7)))) {
367                         // Differs in length.
368                         expected = lhs.length() - rhs.length();
369                     } else {
370                         // The remaining cases differ in charAt(min_ij_index), the characters
371                         // before that are "0123456789abcdef".substring(0, min_ij_index).
372                         for (int k = 0; k < min_ij_index; ++k) {
373                           Assert.assertEquals("0123456789abcdef".charAt(k), lhs.charAt(k));
374                           Assert.assertEquals("0123456789abcdef".charAt(k), rhs.charAt(k));
375                         }
376                         expected = lhs.charAt(min_ij_index) - rhs.charAt(min_ij_index);
377                         Assert.assertFalse(expected == 0);
378                     }
379                 }
380                 if (expected != result) {
381                   throw new Error(
382                       "Mismatch at i=" + i + ", j=" + j + ", expected=" + expected +
383                       ", result=" + result);
384                 }
385                 boolean equalsExpected =
386                     (i == j) ||
387                     // Last string in categories 1 and 2.
388                     (i == 32 && j == 48) || (i == 48 && j == 32) ||
389                     // Last string in categories 4 and 5.
390                     (i == 80 && j == 96) || (i == 96 && j == 80) ||
391                     // Last string in categories 7 and 8.
392                     (i == 128 && j == 144) || (i == 144 && j == 128);
393                 Assert.assertEquals(equalsExpected, $noinline$equals(lhs, rhs));
394             }
395         }
396 
397         try {
398             $noinline$compareTo("", null);
399             Assert.fail();
400         } catch (NullPointerException expected) {
401         }
402         try {
403             $noinline$compareTo(null, "");
404             Assert.fail();
405         } catch (NullPointerException expected) {
406         }
407 
408         Assert.assertFalse($noinline$equals("", null));
409         try {
410             $noinline$equals(null, "");
411             Assert.fail();
412         } catch (NullPointerException expected) {
413         }
414     }
415 
testIndexOf()416     public static void testIndexOf() {
417         String[] prefixes = {
418                 "",
419                 "0",
420                 "01",
421                 "012",
422                 "0123",
423                 "01234",
424                 "012345",
425                 "0123456",
426                 "01234567",
427                 "012345678",
428                 "0123456789",
429                 "0123456789a",
430                 "0123456789ab",
431                 "0123456789abc",
432                 "0123456789abcd",
433                 "0123456789abcdef",
434         };
435         String[] cores = {
436                 "",
437                 "x",
438                 "xx",
439                 "xxx",
440                 "xxxx",
441                 "xxxxx",
442                 "xxxxxx",
443                 "xxxxxxx",
444                 "xxxxxxxx",
445                 "xzx",
446                 "xxzx",
447                 "xxxzx",
448                 "xxxxzx",
449                 "xxxxxzx",
450                 "xxxxxxzx",
451                 "xxxxxxxzx",
452                 "xxxxxxxxzx",
453                 "\u0440",
454                 "\u0440\u0440",
455                 "\u0440\u0440\u0440",
456                 "\u0440\u0440\u0440\u0440",
457                 "\u0440\u0440\u0440\u0440\u0440",
458                 "\u0440\u0440\u0440\u0440\u0440\u0440",
459                 "\u0440\u0440\u0440\u0440\u0440\u0440\u0440",
460                 "\u0440\u0440\u0440\u0440\u0440\u0440\u0440\u0440",
461                 "\u0440z\u0440",
462                 "\u0440\u0440z\u0440",
463                 "\u0440\u0440\u0440z\u0440",
464                 "\u0440\u0440\u0440\u0440z\u0440",
465                 "\u0440\u0440\u0440\u0440\u0440z\u0440",
466                 "\u0440\u0440\u0440\u0440\u0440\u0440z\u0440",
467                 "\u0440\u0440\u0440\u0440\u0440\u0440\u0440z\u0440",
468                 "\u0440\u0440\u0440\u0440\u0440\u0440\u0440\u0440z\u0440",
469                 "\u0000",
470                 "\u0000\u0000",
471                 "\u0000\u0000\u0000",
472                 "\u0000\u0000\u0000\u0000",
473                 "\u0000\u0000\u0000\u0000\u0000",
474                 "\u0000\u0000\u0000\u0000\u0000\u0000",
475                 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000",
476                 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000",
477                 "\u0000z\u0000",
478                 "\u0000\u0000z\u0000",
479                 "\u0000\u0000\u0000z\u0000",
480                 "\u0000\u0000\u0000\u0000z\u0000",
481                 "\u0000\u0000\u0000\u0000\u0000z\u0000",
482                 "\u0000\u0000\u0000\u0000\u0000\u0000z\u0000",
483                 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000z\u0000",
484                 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000z\u0000",
485         };
486         String[] suffixes = {
487                 "",
488                 "y",
489                 "yy",
490                 "yyy",
491                 "yyyy",
492                 "yyyyy",
493                 "yyyyyy",
494                 "yyyyyyy",
495                 "yyyyyyyy",
496                 "\u0441",
497                 "y\u0441",
498                 "yy\u0441",
499                 "yyy\u0441",
500                 "yyyy\u0441",
501                 "yyyyy\u0441",
502                 "yyyyyy\u0441",
503                 "yyyyyyy\u0441",
504                 "yyyyyyyy\u0441",
505         };
506         for (String p : prefixes) {
507             for (String c : cores) {
508                 for (String s : suffixes) {
509                     String full = p + c + s;
510                     int expX = (c.isEmpty() || c.charAt(0) != 'x') ? -1 : p.length();
511                     int exp0440 = (c.isEmpty() || c.charAt(0) != '\u0440') ? -1 : p.length();
512                     int exp0000 = (c.isEmpty() || c.charAt(0) != '\u0000') ? -1 : p.length();
513                     Assert.assertEquals(expX, $noinline$indexOf(full, 'x'));
514                     Assert.assertEquals(exp0440, $noinline$indexOf(full, '\u0440'));
515                     Assert.assertEquals(exp0000, $noinline$indexOf(full, '\u0000'));
516                     Assert.assertEquals(expX, $noinline$indexOf(full, 'x', -1));
517                     Assert.assertEquals(exp0440, $noinline$indexOf(full, '\u0440', -1));
518                     Assert.assertEquals(exp0000, $noinline$indexOf(full, '\u0000', -1));
519                     Assert.assertEquals(-1, $noinline$indexOf(full, 'x', full.length() + 1));
520                     Assert.assertEquals(-1, $noinline$indexOf(full, '\u0440', full.length() + 1));
521                     Assert.assertEquals(-1, $noinline$indexOf(full, '\u0000', full.length() + 1));
522                     for (int from = 0; from != full.length(); ++from) {
523                         final int eX;
524                         final int e0440;
525                         final int e0000;
526                         if (from <= p.length()) {
527                             eX = expX;
528                             e0440 = exp0440;
529                             e0000 = exp0000;
530                         } else if (from >= p.length() + c.length()) {
531                             eX = -1;
532                             e0440 = -1;
533                             e0000 = -1;
534                         } else if (full.charAt(from) == 'z') {
535                             eX = (full.charAt(from + 1) != 'x') ? -1 : from + 1;
536                             e0440 = (full.charAt(from + 1) != '\u0440') ? -1 : from + 1;
537                             e0000 = (full.charAt(from + 1) != '\u0000') ? -1 : from + 1;
538                         } else {
539                             eX = (full.charAt(from) != 'x') ? -1 : from;
540                             e0440 = (full.charAt(from) != '\u0440') ? -1 : from;
541                             e0000 = (full.charAt(from) != '\u0000') ? -1 : from;
542                         }
543                         Assert.assertEquals(eX, $noinline$indexOf(full, 'x', from));
544                         Assert.assertEquals(e0440, $noinline$indexOf(full, '\u0440', from));
545                         Assert.assertEquals(e0000, $noinline$indexOf(full, '\u0000', from));
546                     }
547                 }
548             }
549         }
550     }
551 
testEqualsConstString()552     public static void testEqualsConstString() {
553         Assert.assertTrue($noinline$equalsConstString0(""));
554         Assert.assertFalse($noinline$equalsConstString0("1"));
555 
556         Assert.assertTrue($noinline$equalsConstString3("012"));
557         Assert.assertFalse($noinline$equalsConstString3("01"));
558         Assert.assertFalse($noinline$equalsConstString3("0123"));
559         Assert.assertFalse($noinline$equalsConstString3("01x"));
560         Assert.assertFalse($noinline$equalsConstString3("01\u0440"));
561 
562         Assert.assertTrue($noinline$equalsConstString7("0123456"));
563         Assert.assertFalse($noinline$equalsConstString7("012345"));
564         Assert.assertFalse($noinline$equalsConstString7("01234567"));
565         Assert.assertFalse($noinline$equalsConstString7("012345x"));
566         Assert.assertFalse($noinline$equalsConstString7("012345\u0440"));
567 
568         Assert.assertTrue($noinline$equalsConstString12("012345678901"));
569         Assert.assertFalse($noinline$equalsConstString12("01234567890"));
570         Assert.assertFalse($noinline$equalsConstString12("0123456789012"));
571         Assert.assertFalse($noinline$equalsConstString12("01234567890x"));
572         Assert.assertFalse($noinline$equalsConstString12("01234567890\u0440"));
573 
574         Assert.assertTrue($noinline$equalsConstString14("01234567890123"));
575         Assert.assertFalse($noinline$equalsConstString14("0123456789012"));
576         Assert.assertFalse($noinline$equalsConstString14("012345678901234"));
577         Assert.assertFalse($noinline$equalsConstString14("0123456789012x"));
578         Assert.assertFalse($noinline$equalsConstString14("0123456789012\u0440"));
579 
580         Assert.assertTrue($noinline$equalsConstString24("012345678901234567890123"));
581         Assert.assertFalse($noinline$equalsConstString24("01234567890123456789012"));
582         Assert.assertFalse($noinline$equalsConstString24("0123456789012345678901234"));
583         Assert.assertFalse($noinline$equalsConstString24("01234567890123456789012x"));
584         Assert.assertFalse($noinline$equalsConstString24("01234567890123456789012\u0440"));
585 
586         Assert.assertTrue($noinline$equalsConstString29("01234567890123456789012345678"));
587         Assert.assertFalse($noinline$equalsConstString29("0123456789012345678901234567"));
588         Assert.assertFalse($noinline$equalsConstString29("012345678901234567890123456789"));
589         Assert.assertFalse($noinline$equalsConstString29("0123456789012345678901234567x"));
590         Assert.assertFalse($noinline$equalsConstString29("0123456789012345678901234567\u0440"));
591 
592         Assert.assertTrue($noinline$equalsConstString35("01234567890123456789012345678901234"));
593         Assert.assertFalse($noinline$equalsConstString35("0123456789012345678901234567890123"));
594         Assert.assertFalse($noinline$equalsConstString35("012345678901234567890123456789012345"));
595         Assert.assertFalse($noinline$equalsConstString35("0123456789012345678901234567890123x"));
596         Assert.assertFalse(
597             $noinline$equalsConstString35("0123456789012345678901234567890123\u0440"));
598 
599         Assert.assertTrue($noinline$equalsConstNonAsciiString3("\u044012"));
600         Assert.assertFalse($noinline$equalsConstNonAsciiString3("\u04401"));
601         Assert.assertFalse($noinline$equalsConstNonAsciiString3("\u0440123"));
602         Assert.assertFalse($noinline$equalsConstNonAsciiString3("\u04401x"));
603         Assert.assertFalse($noinline$equalsConstNonAsciiString3("012"));
604 
605         Assert.assertTrue($noinline$equalsConstNonAsciiString7("\u0440123456"));
606         Assert.assertFalse($noinline$equalsConstNonAsciiString7("\u044012345"));
607         Assert.assertFalse($noinline$equalsConstNonAsciiString7("\u04401234567"));
608         Assert.assertFalse($noinline$equalsConstNonAsciiString7("\u044012345x"));
609         Assert.assertFalse($noinline$equalsConstNonAsciiString7("0123456"));
610 
611         Assert.assertTrue($noinline$equalsConstNonAsciiString12("\u044012345678901"));
612         Assert.assertFalse($noinline$equalsConstNonAsciiString12("\u04401234567890"));
613         Assert.assertFalse($noinline$equalsConstNonAsciiString12("\u0440123456789012"));
614         Assert.assertFalse($noinline$equalsConstNonAsciiString12("\u04401234567890x"));
615         Assert.assertFalse($noinline$equalsConstNonAsciiString12("012345678901"));
616 
617         Assert.assertTrue($noinline$equalsConstNonAsciiString14("\u04401234567890123"));
618         Assert.assertFalse($noinline$equalsConstNonAsciiString14("\u0440123456789012"));
619         Assert.assertFalse($noinline$equalsConstNonAsciiString14("\u044012345678901234"));
620         Assert.assertFalse($noinline$equalsConstNonAsciiString14("\u0440123456789012x"));
621         Assert.assertFalse($noinline$equalsConstNonAsciiString14("01234567890123"));
622 
623         Assert.assertTrue($noinline$equalsConstNonAsciiString24("\u044012345678901234567890123"));
624         Assert.assertFalse($noinline$equalsConstNonAsciiString24("\u04401234567890123456789012"));
625         Assert.assertFalse($noinline$equalsConstNonAsciiString24("\u0440123456789012345678901234"));
626         Assert.assertFalse($noinline$equalsConstNonAsciiString24("\u04401234567890123456789012x"));
627         Assert.assertFalse($noinline$equalsConstNonAsciiString24("\012345678901234567890123"));
628 
629         Assert.assertTrue(
630             $noinline$equalsConstNonAsciiString29("\u04401234567890123456789012345678"));
631         Assert.assertFalse(
632             $noinline$equalsConstNonAsciiString29("\u0440123456789012345678901234567"));
633         Assert.assertFalse(
634             $noinline$equalsConstNonAsciiString29("\u044012345678901234567890123456789"));
635         Assert.assertFalse(
636             $noinline$equalsConstNonAsciiString29("\u0440123456789012345678901234567x"));
637         Assert.assertFalse($noinline$equalsConstNonAsciiString29("01234567890123456789012345678"));
638 
639         Assert.assertTrue(
640             $noinline$equalsConstNonAsciiString35("\u04401234567890123456789012345678901234"));
641         Assert.assertFalse(
642             $noinline$equalsConstNonAsciiString35("\u0440123456789012345678901234567890123"));
643         Assert.assertFalse(
644             $noinline$equalsConstNonAsciiString35("\u044012345678901234567890123456789012345"));
645         Assert.assertFalse(
646             $noinline$equalsConstNonAsciiString35("\u0440123456789012345678901234567890123x"));
647         Assert.assertFalse(
648             $noinline$equalsConstNonAsciiString35("01234567890123456789012345678901234"));
649     }
650 
testConstStringEquals()651     public static void testConstStringEquals() {
652         Assert.assertTrue($noinline$constString0Equals(""));
653         Assert.assertFalse($noinline$constString0Equals("1"));
654 
655         Assert.assertTrue($noinline$constString3Equals("012"));
656         Assert.assertFalse($noinline$constString3Equals("01"));
657         Assert.assertFalse($noinline$constString3Equals("0123"));
658         Assert.assertFalse($noinline$constString3Equals("01x"));
659         Assert.assertFalse($noinline$constString3Equals("01\u0440"));
660 
661         Assert.assertTrue($noinline$constString7Equals("0123456"));
662         Assert.assertFalse($noinline$constString7Equals("012345"));
663         Assert.assertFalse($noinline$constString7Equals("01234567"));
664         Assert.assertFalse($noinline$constString7Equals("012345x"));
665         Assert.assertFalse($noinline$constString7Equals("012345\u0440"));
666 
667         Assert.assertTrue($noinline$constString12Equals("012345678901"));
668         Assert.assertFalse($noinline$constString12Equals("01234567890"));
669         Assert.assertFalse($noinline$constString12Equals("0123456789012"));
670         Assert.assertFalse($noinline$constString12Equals("01234567890x"));
671         Assert.assertFalse($noinline$constString12Equals("01234567890\u0440"));
672 
673         Assert.assertTrue($noinline$constString14Equals("01234567890123"));
674         Assert.assertFalse($noinline$constString14Equals("0123456789012"));
675         Assert.assertFalse($noinline$constString14Equals("012345678901234"));
676         Assert.assertFalse($noinline$constString14Equals("0123456789012x"));
677         Assert.assertFalse($noinline$constString14Equals("0123456789012\u0440"));
678 
679         Assert.assertTrue($noinline$constString24Equals("012345678901234567890123"));
680         Assert.assertFalse($noinline$constString24Equals("01234567890123456789012"));
681         Assert.assertFalse($noinline$constString24Equals("0123456789012345678901234"));
682         Assert.assertFalse($noinline$constString24Equals("01234567890123456789012x"));
683         Assert.assertFalse($noinline$constString24Equals("01234567890123456789012\u0440"));
684 
685         Assert.assertTrue($noinline$constString29Equals("01234567890123456789012345678"));
686         Assert.assertFalse($noinline$constString29Equals("0123456789012345678901234567"));
687         Assert.assertFalse($noinline$constString29Equals("012345678901234567890123456789"));
688         Assert.assertFalse($noinline$constString29Equals("0123456789012345678901234567x"));
689         Assert.assertFalse($noinline$constString29Equals("0123456789012345678901234567\u0440"));
690 
691         Assert.assertTrue($noinline$constString35Equals("01234567890123456789012345678901234"));
692         Assert.assertFalse($noinline$constString35Equals("0123456789012345678901234567890123"));
693         Assert.assertFalse($noinline$constString35Equals("012345678901234567890123456789012345"));
694         Assert.assertFalse($noinline$constString35Equals("0123456789012345678901234567890123x"));
695         Assert.assertFalse(
696             $noinline$constString35Equals("0123456789012345678901234567890123\u0040"));
697 
698         Assert.assertTrue($noinline$constNonAsciiString3Equals("\u044012"));
699         Assert.assertFalse($noinline$constNonAsciiString3Equals("\u04401"));
700         Assert.assertFalse($noinline$constNonAsciiString3Equals("\u0440123"));
701         Assert.assertFalse($noinline$constNonAsciiString3Equals("\u04401x"));
702         Assert.assertFalse($noinline$constNonAsciiString3Equals("0123456"));
703 
704         Assert.assertTrue($noinline$constNonAsciiString7Equals("\u0440123456"));
705         Assert.assertFalse($noinline$constNonAsciiString7Equals("\u044012345"));
706         Assert.assertFalse($noinline$constNonAsciiString7Equals("\u04401234567"));
707         Assert.assertFalse($noinline$constNonAsciiString7Equals("\u044012345x"));
708         Assert.assertFalse($noinline$constNonAsciiString7Equals("0123456"));
709 
710         Assert.assertTrue($noinline$constNonAsciiString12Equals("\u044012345678901"));
711         Assert.assertFalse($noinline$constNonAsciiString12Equals("\u04401234567890"));
712         Assert.assertFalse($noinline$constNonAsciiString12Equals("\u0440123456789012"));
713         Assert.assertFalse($noinline$constNonAsciiString12Equals("\u04401234567890x"));
714         Assert.assertFalse($noinline$constNonAsciiString12Equals("012345678901"));
715 
716         Assert.assertTrue($noinline$constNonAsciiString14Equals("\u04401234567890123"));
717         Assert.assertFalse($noinline$constNonAsciiString14Equals("\u0440123456789012"));
718         Assert.assertFalse($noinline$constNonAsciiString14Equals("\u044012345678901234"));
719         Assert.assertFalse($noinline$constNonAsciiString14Equals("\u0440123456789012x"));
720         Assert.assertFalse($noinline$constNonAsciiString14Equals("01234567890123"));
721 
722         Assert.assertTrue($noinline$constNonAsciiString24Equals("\u044012345678901234567890123"));
723         Assert.assertFalse($noinline$constNonAsciiString24Equals("\u04401234567890123456789012"));
724         Assert.assertFalse($noinline$constNonAsciiString24Equals("\u0440123456789012345678901234"));
725         Assert.assertFalse($noinline$constNonAsciiString24Equals("\u04401234567890123456789012x"));
726         Assert.assertFalse($noinline$constNonAsciiString24Equals("\012345678901234567890123"));
727 
728         Assert.assertTrue(
729             $noinline$constNonAsciiString29Equals("\u04401234567890123456789012345678"));
730         Assert.assertFalse(
731             $noinline$constNonAsciiString29Equals("\u0440123456789012345678901234567"));
732         Assert.assertFalse(
733             $noinline$constNonAsciiString29Equals("\u044012345678901234567890123456789"));
734         Assert.assertFalse(
735             $noinline$constNonAsciiString29Equals("\u0440123456789012345678901234567x"));
736         Assert.assertFalse($noinline$constNonAsciiString29Equals("01234567890123456789012345678"));
737 
738         Assert.assertTrue(
739             $noinline$constNonAsciiString35Equals("\u04401234567890123456789012345678901234"));
740         Assert.assertFalse(
741             $noinline$constNonAsciiString35Equals("\u0440123456789012345678901234567890123"));
742         Assert.assertFalse(
743             $noinline$constNonAsciiString35Equals("\u044012345678901234567890123456789012345"));
744         Assert.assertFalse(
745             $noinline$constNonAsciiString35Equals("\u0440123456789012345678901234567890123x"));
746         Assert.assertFalse(
747             $noinline$constNonAsciiString35Equals("01234567890123456789012345678901234"));
748 
749         // Regression test for incorrectly creating an uncompressed string when the
750         // string should be compressed. Only the low 8 bits are relevant but the whole
751         // `hibyte` was erroneously tested. Bug: 63661357
752         Assert.assertTrue("A".equals(new String(new byte[] { (byte)'A' }, /* hibyte */ 0x100)));
753     }
754 
$noinline$equalsConstString0(String s)755     public static boolean $noinline$equalsConstString0(String s) {
756         return s.equals("");
757     }
758 
$noinline$equalsConstString3(String s)759     public static boolean $noinline$equalsConstString3(String s) {
760         return s.equals("012");
761     }
762 
$noinline$equalsConstString7(String s)763     public static boolean $noinline$equalsConstString7(String s) {
764         return s.equals("0123456");
765     }
766 
$noinline$equalsConstString12(String s)767     public static boolean $noinline$equalsConstString12(String s) {
768         return s.equals("012345678901");
769     }
770 
$noinline$equalsConstString14(String s)771     public static boolean $noinline$equalsConstString14(String s) {
772         return s.equals("01234567890123");
773     }
774 
$noinline$equalsConstString24(String s)775     public static boolean $noinline$equalsConstString24(String s) {
776         return s.equals("012345678901234567890123");
777     }
778 
$noinline$equalsConstString29(String s)779     public static boolean $noinline$equalsConstString29(String s) {
780         return s.equals("01234567890123456789012345678");
781     }
782 
$noinline$equalsConstString35(String s)783     public static boolean $noinline$equalsConstString35(String s) {
784         return s.equals("01234567890123456789012345678901234");
785     }
786 
$noinline$equalsConstNonAsciiString3(String s)787     public static boolean $noinline$equalsConstNonAsciiString3(String s) {
788         return s.equals("\u044012");
789     }
790 
$noinline$equalsConstNonAsciiString7(String s)791     public static boolean $noinline$equalsConstNonAsciiString7(String s) {
792         return s.equals("\u0440123456");
793     }
794 
$noinline$equalsConstNonAsciiString12(String s)795     public static boolean $noinline$equalsConstNonAsciiString12(String s) {
796         return s.equals("\u044012345678901");
797     }
798 
$noinline$equalsConstNonAsciiString14(String s)799     public static boolean $noinline$equalsConstNonAsciiString14(String s) {
800         return s.equals("\u04401234567890123");
801     }
802 
$noinline$equalsConstNonAsciiString24(String s)803     public static boolean $noinline$equalsConstNonAsciiString24(String s) {
804         return s.equals("\u044012345678901234567890123");
805     }
806 
$noinline$equalsConstNonAsciiString29(String s)807     public static boolean $noinline$equalsConstNonAsciiString29(String s) {
808         return s.equals("\u04401234567890123456789012345678");
809     }
810 
$noinline$equalsConstNonAsciiString35(String s)811     public static boolean $noinline$equalsConstNonAsciiString35(String s) {
812         return s.equals("\u04401234567890123456789012345678901234");
813     }
814 
$noinline$constString0Equals(String s)815     public static boolean $noinline$constString0Equals(String s) {
816         return s.equals("");
817     }
818 
$noinline$constString3Equals(String s)819     public static boolean $noinline$constString3Equals(String s) {
820         return "012".equals(s);
821     }
822 
$noinline$constString7Equals(String s)823     public static boolean $noinline$constString7Equals(String s) {
824         return "0123456".equals(s);
825     }
826 
$noinline$constString12Equals(String s)827     public static boolean $noinline$constString12Equals(String s) {
828         return "012345678901".equals(s);
829     }
830 
$noinline$constString14Equals(String s)831     public static boolean $noinline$constString14Equals(String s) {
832         return "01234567890123".equals(s);
833     }
834 
$noinline$constString24Equals(String s)835     public static boolean $noinline$constString24Equals(String s) {
836         return "012345678901234567890123".equals(s);
837     }
838 
$noinline$constString29Equals(String s)839     public static boolean $noinline$constString29Equals(String s) {
840         return "01234567890123456789012345678".equals(s);
841     }
842 
$noinline$constString35Equals(String s)843     public static boolean $noinline$constString35Equals(String s) {
844         return "01234567890123456789012345678901234".equals(s);
845     }
846 
$noinline$constNonAsciiString3Equals(String s)847     public static boolean $noinline$constNonAsciiString3Equals(String s) {
848         return "\u044012".equals(s);
849     }
850 
$noinline$constNonAsciiString7Equals(String s)851     public static boolean $noinline$constNonAsciiString7Equals(String s) {
852         return "\u0440123456".equals(s);
853     }
854 
$noinline$constNonAsciiString12Equals(String s)855     public static boolean $noinline$constNonAsciiString12Equals(String s) {
856         return "\u044012345678901".equals(s);
857     }
858 
$noinline$constNonAsciiString14Equals(String s)859     public static boolean $noinline$constNonAsciiString14Equals(String s) {
860         return "\u04401234567890123".equals(s);
861     }
862 
$noinline$constNonAsciiString24Equals(String s)863     public static boolean $noinline$constNonAsciiString24Equals(String s) {
864         return "\u044012345678901234567890123".equals(s);
865     }
866 
$noinline$constNonAsciiString29Equals(String s)867     public static boolean $noinline$constNonAsciiString29Equals(String s) {
868         return "\u04401234567890123456789012345678".equals(s);
869     }
870 
$noinline$constNonAsciiString35Equals(String s)871     public static boolean $noinline$constNonAsciiString35Equals(String s) {
872         return "\u04401234567890123456789012345678901234".equals(s);
873     }
874 
$noinline$compareTo(String lhs, String rhs)875     public static int $noinline$compareTo(String lhs, String rhs) {
876         return lhs.compareTo(rhs);
877     }
878 
$noinline$equals(String lhs, String rhs)879     public static boolean $noinline$equals(String lhs, String rhs) {
880         return lhs.equals(rhs);
881     }
882 
$noinline$indexOf(String lhs, int ch)883     public static int $noinline$indexOf(String lhs, int ch) {
884         return lhs.indexOf(ch);
885     }
886 
$noinline$indexOf(String lhs, int ch, int fromIndex)887     public static int $noinline$indexOf(String lhs, int ch, int fromIndex) {
888         return lhs.indexOf(ch, fromIndex);
889     }
890 }
891