• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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 java.lang.reflect.Method;
18 
19 public class Main {
main(String[] args)20   public static void main(String[] args) {
21     System.out.println($noinline$runSmaliTest("$opt$noinline$foo", new Main()));
22     System.out.println($noinline$runSmaliTest("$opt$noinline$foo", new SubMain()));
23     System.out.println($noinline$runSmaliTest("$opt$noinline$foo", new SubSubMain()));
24   }
25 
bar()26   public int bar() {
27     return 1;
28   }
29 
foo()30   public int foo() {
31     return 2;
32   }
33 
34   public static boolean doThrow = false;
35 
$noinline$runSmaliTest(String name, Main input)36   public static int $noinline$runSmaliTest(String name, Main input) {
37     try {
38       Class<?> c = Class.forName("SmaliTests");
39       Method m = c.getMethod(name, Main.class);
40       return (Integer) m.invoke(null, input);
41     } catch (Exception ex) {
42       throw new Error(ex);
43     }
44   }
45 }
46 
47 class SubMain extends Main {
bar()48   public int bar() {
49     return 3;
50   }
51 
foo()52   public int foo() {
53     return 4;
54   }
55 }
56 
57 class SubSubMain extends SubMain {
bar()58   public int bar() {
59     return 5;
60   }
61 
foo()62   public int foo() {
63     return 6;
64   }
65 }
66