xref: /aosp_15_r20/art/test/2241-checker-inline-try-catch/src/Main.java (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1*795d594fSAndroid Build Coastguard Worker /*
2*795d594fSAndroid Build Coastguard Worker  * Copyright (C) 2022 The Android Open Source Project
3*795d594fSAndroid Build Coastguard Worker  *
4*795d594fSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*795d594fSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*795d594fSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*795d594fSAndroid Build Coastguard Worker  *
8*795d594fSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*795d594fSAndroid Build Coastguard Worker  *
10*795d594fSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*795d594fSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*795d594fSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*795d594fSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*795d594fSAndroid Build Coastguard Worker  * limitations under the License.
15*795d594fSAndroid Build Coastguard Worker  */
16*795d594fSAndroid Build Coastguard Worker 
17*795d594fSAndroid Build Coastguard Worker public class Main {
main(String[] args)18*795d594fSAndroid Build Coastguard Worker   public static void main(String[] args) {
19*795d594fSAndroid Build Coastguard Worker     $noinline$testSingleTryCatch();
20*795d594fSAndroid Build Coastguard Worker     $noinline$testSingleTryCatchTwice();
21*795d594fSAndroid Build Coastguard Worker     $noinline$testSingleTryCatchDifferentInputs();
22*795d594fSAndroid Build Coastguard Worker     $noinline$testDifferentTryCatches();
23*795d594fSAndroid Build Coastguard Worker     $noinline$testTryCatchFinally();
24*795d594fSAndroid Build Coastguard Worker     $noinline$testTryCatchFinallyDifferentInputs();
25*795d594fSAndroid Build Coastguard Worker     $noinline$testRecursiveTryCatch();
26*795d594fSAndroid Build Coastguard Worker     $noinline$testDoNotInlineInsideTryInlineInsideCatch();
27*795d594fSAndroid Build Coastguard Worker     $noinline$testInlineInsideNestedCatches();
28*795d594fSAndroid Build Coastguard Worker     $noinline$testBeforeAfterTryCatch();
29*795d594fSAndroid Build Coastguard Worker     $noinline$testDifferentTypes();
30*795d594fSAndroid Build Coastguard Worker     $noinline$testRawThrow();
31*795d594fSAndroid Build Coastguard Worker     $noinline$testRawThrowTwice();
32*795d594fSAndroid Build Coastguard Worker     $noinline$testThrowCaughtInOuterMethod();
33*795d594fSAndroid Build Coastguard Worker   }
34*795d594fSAndroid Build Coastguard Worker 
$noinline$assertEquals(int expected, int result)35*795d594fSAndroid Build Coastguard Worker   public static void $noinline$assertEquals(int expected, int result) {
36*795d594fSAndroid Build Coastguard Worker     if (expected != result) {
37*795d594fSAndroid Build Coastguard Worker       throw new Error("Expected: " + expected + ", found: " + result);
38*795d594fSAndroid Build Coastguard Worker     }
39*795d594fSAndroid Build Coastguard Worker   }
40*795d594fSAndroid Build Coastguard Worker 
41*795d594fSAndroid Build Coastguard Worker   // Basic try catch inline.
$noinline$testSingleTryCatch()42*795d594fSAndroid Build Coastguard Worker   private static void $noinline$testSingleTryCatch() {
43*795d594fSAndroid Build Coastguard Worker     int[] numbers = {};
44*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(1, $inline$OOBTryCatch(numbers));
45*795d594fSAndroid Build Coastguard Worker   }
46*795d594fSAndroid Build Coastguard Worker 
47*795d594fSAndroid Build Coastguard Worker   // Two instances of the same method with a try catch.
$noinline$testSingleTryCatchTwice()48*795d594fSAndroid Build Coastguard Worker   private static void $noinline$testSingleTryCatchTwice() {
49*795d594fSAndroid Build Coastguard Worker     int[] numbers = {};
50*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(1, $inline$OOBTryCatch(numbers));
51*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(1, $inline$OOBTryCatch(numbers));
52*795d594fSAndroid Build Coastguard Worker   }
53*795d594fSAndroid Build Coastguard Worker 
54*795d594fSAndroid Build Coastguard Worker   // Triggering both normal and the exceptional flow.
$noinline$testSingleTryCatchDifferentInputs()55*795d594fSAndroid Build Coastguard Worker   private static void $noinline$testSingleTryCatchDifferentInputs() {
56*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(1, $inline$OOBTryCatch(null));
57*795d594fSAndroid Build Coastguard Worker     int[] numbers = {};
58*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(1, $inline$OOBTryCatch(numbers));
59*795d594fSAndroid Build Coastguard Worker     int[] filled_numbers = {42};
60*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(42, $inline$OOBTryCatch(filled_numbers));
61*795d594fSAndroid Build Coastguard Worker   }
62*795d594fSAndroid Build Coastguard Worker 
63*795d594fSAndroid Build Coastguard Worker 
64*795d594fSAndroid Build Coastguard Worker   // Two different try catches, with the same catch's dex_pc.
$noinline$testDifferentTryCatches()65*795d594fSAndroid Build Coastguard Worker   private static void $noinline$testDifferentTryCatches() {
66*795d594fSAndroid Build Coastguard Worker     int[] numbers = {};
67*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(1, $inline$OOBTryCatch(numbers));
68*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(2, $inline$OtherOOBTryCatch(numbers));
69*795d594fSAndroid Build Coastguard Worker   }
70*795d594fSAndroid Build Coastguard Worker 
71*795d594fSAndroid Build Coastguard Worker   // Basic try/catch/finally.
$noinline$testTryCatchFinally()72*795d594fSAndroid Build Coastguard Worker   private static void $noinline$testTryCatchFinally() {
73*795d594fSAndroid Build Coastguard Worker     int[] numbers = {};
74*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(3, $inline$OOBTryCatchFinally(numbers));
75*795d594fSAndroid Build Coastguard Worker   }
76*795d594fSAndroid Build Coastguard Worker 
77*795d594fSAndroid Build Coastguard Worker   // Triggering both normal and the exceptional flow.
$noinline$testTryCatchFinallyDifferentInputs()78*795d594fSAndroid Build Coastguard Worker   private static void $noinline$testTryCatchFinallyDifferentInputs() {
79*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(3, $inline$OOBTryCatchFinally(null));
80*795d594fSAndroid Build Coastguard Worker     int[] numbers = {};
81*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(3, $inline$OOBTryCatchFinally(numbers));
82*795d594fSAndroid Build Coastguard Worker     int[] filled_numbers = {42};
83*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(42, $inline$OOBTryCatchFinally(filled_numbers));
84*795d594fSAndroid Build Coastguard Worker   }
85*795d594fSAndroid Build Coastguard Worker 
86*795d594fSAndroid Build Coastguard Worker   // Test that we can inline even when the try catch is several levels deep.
$noinline$testRecursiveTryCatch()87*795d594fSAndroid Build Coastguard Worker   private static void $noinline$testRecursiveTryCatch() {
88*795d594fSAndroid Build Coastguard Worker     int[] numbers = {};
89*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(1, $inline$OOBTryCatchLevel4(numbers));
90*795d594fSAndroid Build Coastguard Worker   }
91*795d594fSAndroid Build Coastguard Worker 
92*795d594fSAndroid Build Coastguard Worker   // Tests that we don't inline inside outer tries, but we do inline inside of catches.
93*795d594fSAndroid Build Coastguard Worker   /// CHECK-START: void Main.$noinline$testDoNotInlineInsideTryInlineInsideCatch() inliner (before)
94*795d594fSAndroid Build Coastguard Worker   /// CHECK:       InvokeStaticOrDirect method_name:Main.DoNotInlineOOBTryCatch
95*795d594fSAndroid Build Coastguard Worker   /// CHECK:       InvokeStaticOrDirect method_name:Main.$inline$OOBTryCatch
96*795d594fSAndroid Build Coastguard Worker 
97*795d594fSAndroid Build Coastguard Worker   /// CHECK-START: void Main.$noinline$testDoNotInlineInsideTryInlineInsideCatch() inliner (after)
98*795d594fSAndroid Build Coastguard Worker   /// CHECK:       InvokeStaticOrDirect method_name:Main.DoNotInlineOOBTryCatch
$noinline$testDoNotInlineInsideTryInlineInsideCatch()99*795d594fSAndroid Build Coastguard Worker   private static void $noinline$testDoNotInlineInsideTryInlineInsideCatch() {
100*795d594fSAndroid Build Coastguard Worker     int val = 0;
101*795d594fSAndroid Build Coastguard Worker     try {
102*795d594fSAndroid Build Coastguard Worker       int[] numbers = {};
103*795d594fSAndroid Build Coastguard Worker       val = DoNotInlineOOBTryCatch(numbers);
104*795d594fSAndroid Build Coastguard Worker     } catch (Exception ex) {
105*795d594fSAndroid Build Coastguard Worker       unreachable();
106*795d594fSAndroid Build Coastguard Worker       // This is unreachable but we will still compile it so it works for checking that it inlines.
107*795d594fSAndroid Build Coastguard Worker       int[] numbers = {};
108*795d594fSAndroid Build Coastguard Worker       $inline$OOBTryCatch(numbers);
109*795d594fSAndroid Build Coastguard Worker     }
110*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(1, val);
111*795d594fSAndroid Build Coastguard Worker   }
112*795d594fSAndroid Build Coastguard Worker 
$noinline$emptyMethod()113*795d594fSAndroid Build Coastguard Worker   private static void $noinline$emptyMethod() {}
114*795d594fSAndroid Build Coastguard Worker 
$inline$testInlineInsideNestedCatches_inner()115*795d594fSAndroid Build Coastguard Worker   private static void $inline$testInlineInsideNestedCatches_inner() {
116*795d594fSAndroid Build Coastguard Worker     try {
117*795d594fSAndroid Build Coastguard Worker       $noinline$emptyMethod();
118*795d594fSAndroid Build Coastguard Worker     } catch (Exception ex) {
119*795d594fSAndroid Build Coastguard Worker       int[] numbers = {};
120*795d594fSAndroid Build Coastguard Worker       $noinline$assertEquals(1, $inline$OOBTryCatch(numbers));
121*795d594fSAndroid Build Coastguard Worker     }
122*795d594fSAndroid Build Coastguard Worker   }
123*795d594fSAndroid Build Coastguard Worker 
$noinline$testInlineInsideNestedCatches()124*795d594fSAndroid Build Coastguard Worker   private static void $noinline$testInlineInsideNestedCatches() {
125*795d594fSAndroid Build Coastguard Worker     try {
126*795d594fSAndroid Build Coastguard Worker       $noinline$emptyMethod();
127*795d594fSAndroid Build Coastguard Worker     } catch (Exception ex) {
128*795d594fSAndroid Build Coastguard Worker       $inline$testInlineInsideNestedCatches_inner();
129*795d594fSAndroid Build Coastguard Worker     }
130*795d594fSAndroid Build Coastguard Worker   }
131*795d594fSAndroid Build Coastguard Worker 
132*795d594fSAndroid Build Coastguard Worker   // Tests that outer tries or catches don't affect as long as we are not inlining the inner
133*795d594fSAndroid Build Coastguard Worker   // try/catch inside of them.
$noinline$testBeforeAfterTryCatch()134*795d594fSAndroid Build Coastguard Worker   private static void $noinline$testBeforeAfterTryCatch() {
135*795d594fSAndroid Build Coastguard Worker     int[] numbers = {};
136*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(1, $inline$OOBTryCatch(numbers));
137*795d594fSAndroid Build Coastguard Worker 
138*795d594fSAndroid Build Coastguard Worker     // Unrelated try catch does not block inlining outside of it. We fill it in to make sure it is
139*795d594fSAndroid Build Coastguard Worker     // still there by the time the inliner runs.
140*795d594fSAndroid Build Coastguard Worker     int val = 0;
141*795d594fSAndroid Build Coastguard Worker     try {
142*795d594fSAndroid Build Coastguard Worker       int[] other_array = {};
143*795d594fSAndroid Build Coastguard Worker       val = other_array[0];
144*795d594fSAndroid Build Coastguard Worker     } catch (Exception ex) {
145*795d594fSAndroid Build Coastguard Worker       $noinline$assertEquals(0, val);
146*795d594fSAndroid Build Coastguard Worker       val = 1;
147*795d594fSAndroid Build Coastguard Worker     }
148*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(1, val);
149*795d594fSAndroid Build Coastguard Worker 
150*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(1, $inline$OOBTryCatch(numbers));
151*795d594fSAndroid Build Coastguard Worker   }
152*795d594fSAndroid Build Coastguard Worker 
153*795d594fSAndroid Build Coastguard Worker   // Tests different try catch types in the same outer method.
$noinline$testDifferentTypes()154*795d594fSAndroid Build Coastguard Worker   private static void $noinline$testDifferentTypes() {
155*795d594fSAndroid Build Coastguard Worker     int[] numbers = {};
156*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(1, $inline$OOBTryCatch(numbers));
157*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(2, $inline$OtherOOBTryCatch(numbers));
158*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(123, $inline$ParseIntTryCatch("123"));
159*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(-1, $inline$ParseIntTryCatch("abc"));
160*795d594fSAndroid Build Coastguard Worker   }
161*795d594fSAndroid Build Coastguard Worker 
162*795d594fSAndroid Build Coastguard Worker   // Tests a raw throw (rather than an instruction that happens to throw).
$noinline$testRawThrow()163*795d594fSAndroid Build Coastguard Worker   private static void $noinline$testRawThrow() {
164*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(1, $inline$rawThrowCaught());
165*795d594fSAndroid Build Coastguard Worker   }
166*795d594fSAndroid Build Coastguard Worker 
167*795d594fSAndroid Build Coastguard Worker   // Tests a raw throw twice.
$noinline$testRawThrowTwice()168*795d594fSAndroid Build Coastguard Worker   private static void $noinline$testRawThrowTwice() {
169*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(1, $inline$rawThrowCaught());
170*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(1, $inline$rawThrowCaught());
171*795d594fSAndroid Build Coastguard Worker   }
172*795d594fSAndroid Build Coastguard Worker 
173*795d594fSAndroid Build Coastguard Worker   // Tests that the outer method can successfully catch the throw in the inner method.
$noinline$testThrowCaughtInOuterMethod()174*795d594fSAndroid Build Coastguard Worker   private static void $noinline$testThrowCaughtInOuterMethod() {
175*795d594fSAndroid Build Coastguard Worker     int[] numbers = {};
176*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(1, $inline$testThrowCaughtInOuterMethod_simpleTryCatch(numbers));
177*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(1, $inline$testThrowCaughtInOuterMethod_simpleTryCatch_inliningInner(numbers));
178*795d594fSAndroid Build Coastguard Worker     $noinline$assertEquals(1, $inline$testThrowCaughtInOuterMethod_withFinally(numbers));
179*795d594fSAndroid Build Coastguard Worker   }
180*795d594fSAndroid Build Coastguard Worker 
181*795d594fSAndroid Build Coastguard Worker   // Building blocks for the test functions.
$inline$OOBTryCatch(int[] array)182*795d594fSAndroid Build Coastguard Worker   private static int $inline$OOBTryCatch(int[] array) {
183*795d594fSAndroid Build Coastguard Worker     try {
184*795d594fSAndroid Build Coastguard Worker       return array[0];
185*795d594fSAndroid Build Coastguard Worker     } catch (Exception e) {
186*795d594fSAndroid Build Coastguard Worker       return 1;
187*795d594fSAndroid Build Coastguard Worker     }
188*795d594fSAndroid Build Coastguard Worker   }
189*795d594fSAndroid Build Coastguard Worker 
$inline$OtherOOBTryCatch(int[] array)190*795d594fSAndroid Build Coastguard Worker   private static int $inline$OtherOOBTryCatch(int[] array) {
191*795d594fSAndroid Build Coastguard Worker     try {
192*795d594fSAndroid Build Coastguard Worker       return array[0];
193*795d594fSAndroid Build Coastguard Worker     } catch (Exception e) {
194*795d594fSAndroid Build Coastguard Worker       return 2;
195*795d594fSAndroid Build Coastguard Worker     }
196*795d594fSAndroid Build Coastguard Worker   }
197*795d594fSAndroid Build Coastguard Worker 
$inline$OOBTryCatchFinally(int[] array)198*795d594fSAndroid Build Coastguard Worker   private static int $inline$OOBTryCatchFinally(int[] array) {
199*795d594fSAndroid Build Coastguard Worker     int val = 0;
200*795d594fSAndroid Build Coastguard Worker     try {
201*795d594fSAndroid Build Coastguard Worker       val = 1;
202*795d594fSAndroid Build Coastguard Worker       return array[0];
203*795d594fSAndroid Build Coastguard Worker     } catch (Exception e) {
204*795d594fSAndroid Build Coastguard Worker       val = 2;
205*795d594fSAndroid Build Coastguard Worker     } finally {
206*795d594fSAndroid Build Coastguard Worker       val = 3;
207*795d594fSAndroid Build Coastguard Worker     }
208*795d594fSAndroid Build Coastguard Worker     return val;
209*795d594fSAndroid Build Coastguard Worker   }
210*795d594fSAndroid Build Coastguard Worker 
211*795d594fSAndroid Build Coastguard Worker   // If we make the depthness a parameter, we wouldn't be able to mark as $inline$ and we would
212*795d594fSAndroid Build Coastguard Worker   // need extra CHECKer statements.
$inline$OOBTryCatchLevel4(int[] array)213*795d594fSAndroid Build Coastguard Worker   private static int $inline$OOBTryCatchLevel4(int[] array) {
214*795d594fSAndroid Build Coastguard Worker     return $inline$OOBTryCatchLevel3(array);
215*795d594fSAndroid Build Coastguard Worker   }
216*795d594fSAndroid Build Coastguard Worker 
$inline$OOBTryCatchLevel3(int[] array)217*795d594fSAndroid Build Coastguard Worker   private static int $inline$OOBTryCatchLevel3(int[] array) {
218*795d594fSAndroid Build Coastguard Worker     return $inline$OOBTryCatchLevel2(array);
219*795d594fSAndroid Build Coastguard Worker   }
220*795d594fSAndroid Build Coastguard Worker 
$inline$OOBTryCatchLevel2(int[] array)221*795d594fSAndroid Build Coastguard Worker   private static int $inline$OOBTryCatchLevel2(int[] array) {
222*795d594fSAndroid Build Coastguard Worker     return $inline$OOBTryCatchLevel1(array);
223*795d594fSAndroid Build Coastguard Worker   }
224*795d594fSAndroid Build Coastguard Worker 
$inline$OOBTryCatchLevel1(int[] array)225*795d594fSAndroid Build Coastguard Worker   private static int $inline$OOBTryCatchLevel1(int[] array) {
226*795d594fSAndroid Build Coastguard Worker     return $inline$OOBTryCatch(array);
227*795d594fSAndroid Build Coastguard Worker   }
228*795d594fSAndroid Build Coastguard Worker 
DoNotInlineOOBTryCatch(int[] array)229*795d594fSAndroid Build Coastguard Worker   private static int DoNotInlineOOBTryCatch(int[] array) {
230*795d594fSAndroid Build Coastguard Worker     try {
231*795d594fSAndroid Build Coastguard Worker       return array[0];
232*795d594fSAndroid Build Coastguard Worker     } catch (Exception e) {
233*795d594fSAndroid Build Coastguard Worker       return 1;
234*795d594fSAndroid Build Coastguard Worker     }
235*795d594fSAndroid Build Coastguard Worker   }
236*795d594fSAndroid Build Coastguard Worker 
unreachable()237*795d594fSAndroid Build Coastguard Worker   private static void unreachable() {
238*795d594fSAndroid Build Coastguard Worker     throw new Error("Unreachable");
239*795d594fSAndroid Build Coastguard Worker   }
240*795d594fSAndroid Build Coastguard Worker 
$inline$ParseIntTryCatch(String str)241*795d594fSAndroid Build Coastguard Worker   private static int $inline$ParseIntTryCatch(String str) {
242*795d594fSAndroid Build Coastguard Worker     try {
243*795d594fSAndroid Build Coastguard Worker       return Integer.parseInt(str);
244*795d594fSAndroid Build Coastguard Worker     } catch (NumberFormatException ex) {
245*795d594fSAndroid Build Coastguard Worker       return -1;
246*795d594fSAndroid Build Coastguard Worker     }
247*795d594fSAndroid Build Coastguard Worker   }
248*795d594fSAndroid Build Coastguard Worker 
$inline$rawThrowCaught()249*795d594fSAndroid Build Coastguard Worker   private static int $inline$rawThrowCaught() {
250*795d594fSAndroid Build Coastguard Worker     try {
251*795d594fSAndroid Build Coastguard Worker       throw new Error();
252*795d594fSAndroid Build Coastguard Worker     } catch (Error e) {
253*795d594fSAndroid Build Coastguard Worker       return 1;
254*795d594fSAndroid Build Coastguard Worker     }
255*795d594fSAndroid Build Coastguard Worker   }
256*795d594fSAndroid Build Coastguard Worker 
$inline$testThrowCaughtInOuterMethod_simpleTryCatch(int[] array)257*795d594fSAndroid Build Coastguard Worker   private static int $inline$testThrowCaughtInOuterMethod_simpleTryCatch(int[] array) {
258*795d594fSAndroid Build Coastguard Worker     int val = 0;
259*795d594fSAndroid Build Coastguard Worker     try {
260*795d594fSAndroid Build Coastguard Worker       $noinline$throwingMethod(array);
261*795d594fSAndroid Build Coastguard Worker     } catch (Exception ex) {
262*795d594fSAndroid Build Coastguard Worker       val = 1;
263*795d594fSAndroid Build Coastguard Worker     }
264*795d594fSAndroid Build Coastguard Worker     return val;
265*795d594fSAndroid Build Coastguard Worker   }
266*795d594fSAndroid Build Coastguard Worker 
$noinline$throwingMethod(int[] array)267*795d594fSAndroid Build Coastguard Worker   private static int $noinline$throwingMethod(int[] array) {
268*795d594fSAndroid Build Coastguard Worker     return array[0];
269*795d594fSAndroid Build Coastguard Worker   }
270*795d594fSAndroid Build Coastguard Worker 
$inline$testThrowCaughtInOuterMethod_simpleTryCatch_inliningInner(int[] array)271*795d594fSAndroid Build Coastguard Worker   private static int $inline$testThrowCaughtInOuterMethod_simpleTryCatch_inliningInner(int[] array) {
272*795d594fSAndroid Build Coastguard Worker     int val = 0;
273*795d594fSAndroid Build Coastguard Worker     try {
274*795d594fSAndroid Build Coastguard Worker       $inline$throwingMethod(array);
275*795d594fSAndroid Build Coastguard Worker     } catch (Exception ex) {
276*795d594fSAndroid Build Coastguard Worker       val = 1;
277*795d594fSAndroid Build Coastguard Worker     }
278*795d594fSAndroid Build Coastguard Worker     return val;
279*795d594fSAndroid Build Coastguard Worker   }
280*795d594fSAndroid Build Coastguard Worker 
$inline$throwingMethod(int[] array)281*795d594fSAndroid Build Coastguard Worker   private static int $inline$throwingMethod(int[] array) {
282*795d594fSAndroid Build Coastguard Worker     return array[0];
283*795d594fSAndroid Build Coastguard Worker   }
284*795d594fSAndroid Build Coastguard Worker 
$inline$testThrowCaughtInOuterMethod_withFinally(int[] array)285*795d594fSAndroid Build Coastguard Worker   private static int $inline$testThrowCaughtInOuterMethod_withFinally(int[] array) {
286*795d594fSAndroid Build Coastguard Worker     int val = 0;
287*795d594fSAndroid Build Coastguard Worker     try {
288*795d594fSAndroid Build Coastguard Worker       $noinline$throwingMethodWithFinally(array);
289*795d594fSAndroid Build Coastguard Worker     } catch (Exception ex) {
290*795d594fSAndroid Build Coastguard Worker       System.out.println("Our battle it will be legendary!");
291*795d594fSAndroid Build Coastguard Worker       val = 1;
292*795d594fSAndroid Build Coastguard Worker     }
293*795d594fSAndroid Build Coastguard Worker     return val;
294*795d594fSAndroid Build Coastguard Worker   }
295*795d594fSAndroid Build Coastguard Worker 
$noinline$throwingMethodWithFinally(int[] array)296*795d594fSAndroid Build Coastguard Worker   private static int $noinline$throwingMethodWithFinally(int[] array) {
297*795d594fSAndroid Build Coastguard Worker     try {
298*795d594fSAndroid Build Coastguard Worker       return array[0];
299*795d594fSAndroid Build Coastguard Worker     } finally {
300*795d594fSAndroid Build Coastguard Worker       System.out.println("Finally, a worthy opponent!");
301*795d594fSAndroid Build Coastguard Worker     }
302*795d594fSAndroid Build Coastguard Worker   }
303*795d594fSAndroid Build Coastguard Worker }
304