1 /*
2  * Copyright (C) 2008 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 /**
18  * Dalvik instruction exerciser.
19  */
20 public class Main {
21     /*
22      * Start up.
23      */
main(String[] args)24     public static void main(String[] args) {
25         Main main = new Main();
26         main.run();
27 
28         /* run through the heap to see if we trashed something */
29         Runtime.getRuntime().gc();
30 
31         System.out.println("Done!");
32     }
33 
run()34     public void run() {
35         InstField instField = new InstField();
36         instField.run();
37 
38         StaticField.run();
39 
40         IntMath.run();
41         FloatMath.run();
42         Compare.run();
43 
44         Monitor.run();
45         Switch.run();
46         Array.run();
47         Classes.run();
48         Goto.run();
49         MethodCall.run();
50         Throw.run();
51 
52         try {
53             UnresTest1.run();
54         } catch (VerifyError ve) {
55             System.out.println("Caught: " + ve);
56         }
57         try {
58             UnresTest1.run();
59         } catch (VerifyError ve) {
60             System.out.println("Caught (retry): " + ve);
61         }
62 
63         try {
64             UnresTest2.run();
65         } catch (VerifyError ve) {
66             System.out.println("Caught: " + ve);
67         } catch (Throwable th) {
68             // We and the RI throw ClassNotFoundException, but that isn't declared so javac
69             // won't let us try to catch it.
70             th.printStackTrace(System.out);
71         }
72         InternedString.run();
73         GenSelect.run();
74     }
75 
assertTrue(boolean condition)76     public static void assertTrue(boolean condition) {
77         if (!condition) {
78             throw new Error();
79         }
80     }
81 }
82