15d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao/*
25d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * Copyright (C) 2008 The Android Open Source Project
35d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao *
45d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * Licensed under the Apache License, Version 2.0 (the "License");
55d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * you may not use this file except in compliance with the License.
65d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * You may obtain a copy of the License at
75d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao *
85d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao *      http://www.apache.org/licenses/LICENSE-2.0
95d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao *
105d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * Unless required by applicable law or agreed to in writing, software
115d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * distributed under the License is distributed on an "AS IS" BASIS,
125d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
135d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * See the License for the specific language governing permissions and
145d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * limitations under the License.
155d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao */
165d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao
175d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao/**
185d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao * Dalvik instruction exerciser.
195d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao */
205d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhaopublic class Main {
215d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao    /*
225d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao     * Start up.
235d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao     */
245d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao    public static void main(String[] args) {
255d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        Main main = new Main();
265d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        main.run();
275d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao
285d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        /* run through the heap to see if we trashed something */
297befd0e35bbed32b90bc0c8b6d3fa8bd612f5506Mathieu Chartier        Runtime.getRuntime().gc();
305d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao
315d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        System.out.println("Done!");
325d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao    }
335d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao
345d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao    public void run() {
355d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        InstField instField = new InstField();
365d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        instField.run();
375d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao
385d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        StaticField.run();
395d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao
405d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        IntMath.run();
415d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        FloatMath.run();
425d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        Compare.run();
435d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao
445d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        Monitor.run();
455d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        Switch.run();
465d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        Array.run();
475d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        Classes.run();
485d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        Goto.run();
495d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        MethodCall.run();
505d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        Throw.run();
515d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao
525d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        try {
535d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao            UnresTest1.run();
545d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        } catch (VerifyError ve) {
555d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao            System.out.println("Caught: " + ve);
565d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        }
575d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        try {
585d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao            UnresTest1.run();
595d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        } catch (VerifyError ve) {
605d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao            System.out.println("Caught (retry): " + ve);
615d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        }
625d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao
635d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        try {
645d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao            UnresTest2.run();
655d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        } catch (VerifyError ve) {
665d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao            System.out.println("Caught: " + ve);
67748382f38dfe7a0d9a426a4b72fcfc399ba1a5daElliott Hughes        } catch (Throwable th) {
68748382f38dfe7a0d9a426a4b72fcfc399ba1a5daElliott Hughes            // We and the RI throw ClassNotFoundException, but that isn't declared so javac
69748382f38dfe7a0d9a426a4b72fcfc399ba1a5daElliott Hughes            // won't let us try to catch it.
70748382f38dfe7a0d9a426a4b72fcfc399ba1a5daElliott Hughes            th.printStackTrace();
715d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        }
725d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao        InternedString.run();
733f51e7d942c22edaab3a7e703a1e6a2dd6a26f77Jean Christophe Beyler        GenSelect.run();
745d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao    }
75795d78f4d04c8d007bf2bdf2ed4131379bcf19c7jeffhao
76795d78f4d04c8d007bf2bdf2ed4131379bcf19c7jeffhao    public static void assertTrue(boolean condition) {
77795d78f4d04c8d007bf2bdf2ed4131379bcf19c7jeffhao        if (!condition) {
78795d78f4d04c8d007bf2bdf2ed4131379bcf19c7jeffhao            throw new Error();
79795d78f4d04c8d007bf2bdf2ed4131379bcf19c7jeffhao        }
80795d78f4d04c8d007bf2bdf2ed4131379bcf19c7jeffhao    }
815d1ac920fdaef5d4ec8f66bb734488cd9660b024jeffhao}
82