diff options
author | 2019-12-13 12:53:39 +0000 | |
---|---|---|
committer | 2020-01-08 14:50:06 +0000 | |
commit | a18f5aeaecf9088f1ba1c43e7577dc149f85673f (patch) | |
tree | 88a98d98edab2c83821a8df17768788245c039a1 /test/699-checker-string-append2/src/Main.java | |
parent | 7ee34a1eeba20c1b438f7bcad75adba65dd2a840 (diff) |
Fix StringBuilder append assumptions.
Do not rely on use ordering, it can be different because of
SimplifyReturnThis(); just use HBackwardInstructionIterator.
Instead of checking that we find a StringBuilder.toString(),
check that it is the invoke we're trying to simplify.
Add regression test 699-checker-string-append2.
Test: testrunner.py --host --jvm -t 699-checker-string-append2
Bug: 19575890
Bug: 146014745
Change-Id: I7b16f376c16ba5a4107e9718e0acf17d82280f54
Diffstat (limited to 'test/699-checker-string-append2/src/Main.java')
-rw-r--r-- | test/699-checker-string-append2/src/Main.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/699-checker-string-append2/src/Main.java b/test/699-checker-string-append2/src/Main.java new file mode 100644 index 0000000000..3753af603b --- /dev/null +++ b/test/699-checker-string-append2/src/Main.java @@ -0,0 +1,40 @@ +/* + * Copyright 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.lang.reflect.Method; + +public class Main { + public static void main(String[] args) throws Exception { + Class<?> c = Class.forName("B146014745"); + Method m1 = c.getDeclaredMethod("$noinline$testAppend1", String.class, int.class); + String b146014745_result1 = (String) m1.invoke(null, "x", 42); + assertEquals("x42x42", b146014745_result1); + Method m2 = c.getDeclaredMethod("$noinline$testAppend2", String.class, int.class); + String b146014745_result2 = (String) m2.invoke(null, "x", 42); + assertEquals("x42x42", b146014745_result2); + Method m3 = c.getDeclaredMethod("$noinline$testAppend3", String.class, int.class); + String b146014745_result3 = (String) m3.invoke(null, "x", 42); + assertEquals("x42x42", b146014745_result3); + + System.out.println("passed"); + } + + public static void assertEquals(String expected, String actual) { + if (!expected.equals(actual)) { + throw new AssertionError("Expected: " + expected + ", actual: " + actual); + } + } +} |