• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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         boolean assertEnabled = false;
26         assert assertEnabled = true;
27         if (!assertEnabled) {
28             System.out.println("FAIL: assert doesn't work (specify '-ea')\n");
29             throw new RuntimeException();
30         } else {
31             System.out.println("(assertions are enabled)");
32         }
33 
34         Main main = new Main();
35         main.run();
36 
37         /* run through the heap to see if we trashed something */
38         System.gc();
39 
40         System.out.println("Done!");
41     }
42 
run()43     public void run() {
44         InstField instField = new InstField();
45         instField.run();
46 
47         StaticField.run();
48 
49         IntMath.run();
50         FloatMath.run();
51         Compare.run();
52 
53         Monitor.run();
54         Switch.run();
55         Array.run();
56         Classes.run();
57         Goto.run();
58         MethodCall.run();
59         Throw.run();
60 
61         try {
62             UnresTest1.run();
63         } catch (VerifyError ve) {
64             System.out.println("Caught: " + ve);
65         }
66         try {
67             UnresTest1.run();
68         } catch (VerifyError ve) {
69             System.out.println("Caught (retry): " + ve);
70         }
71 
72         try {
73             UnresTest2.run();
74         } catch (VerifyError ve) {
75             System.out.println("Caught: " + ve);
76         } catch (NoClassDefFoundError ncdfe) {
77             /* UnresClass can cause desktop Java to freak out */
78             System.out.println("NOTE: UnresTest2 not available");
79         }
80         InternedString.run();
81     }
82 }
83