blob: aa08137caa3068e76054c5862cdb8f470d202063 [file] [log] [blame]
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +00001/*
2 * Copyright (C) 2014 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// Note that $opt$ is a marker for the optimizing compiler to ensure
18// it does compile the method.
19
20public class Main {
21 public static void main(String[] args) {
22 Error error = null;
23 try {
24 $opt$TestInvokeStatic();
25 } catch (Error e) {
26 error = e;
27 }
28 System.out.println(error);
Nicolas Geoffray2e7038a2014-04-03 18:49:58 +010029
30 $opt$TestInvokeNew();
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +000031 }
32
33 public static void $opt$TestInvokeStatic() {
34 printStaticMethod();
Nicolas Geoffray4a34a422014-04-03 10:38:37 +010035 printStaticMethodWith2Args(1, 2);
36 printStaticMethodWith5Args(1, 2, 3, 4, 5);
37 printStaticMethodWith7Args(1, 2, 3, 4, 5, 6, 7);
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +000038 forceGCStaticMethod();
39 throwStaticMethod();
40 }
41
Nicolas Geoffray2e7038a2014-04-03 18:49:58 +010042 public static void $opt$TestInvokeNew() {
43 Object o = new Object();
44 forceGCStaticMethod();
45 printStaticMethodWithObjectArg(o);
46 forceGCStaticMethod();
47 }
48
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +000049 public static void printStaticMethod() {
50 System.out.println("In static method");
51 }
52
Nicolas Geoffray4a34a422014-04-03 10:38:37 +010053 public static void printStaticMethodWith2Args(int a, int b) {
54 System.out.println("In static method with 2 args " + a + " " + b);
55 }
56
57 public static void printStaticMethodWith5Args(int a, int b, int c, int d, int e) {
58 System.out.println("In static method with 5 args "
59 + a + " " + b + " " + c + " " + d + " " + e);
60 }
61
62 public static void printStaticMethodWith7Args(int a, int b, int c, int d, int e, int f, int g) {
63 System.out.println("In static method with 7 args "
64 + a + " " + b + " " + c + " " + d + " " + e + " " + f + " " + g);
65 }
66
Nicolas Geoffray2e7038a2014-04-03 18:49:58 +010067 public static void printStaticMethodWithObjectArg(Object a) {
68 System.out.println("In static method with object arg " + a.getClass());
69 }
70
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +000071 public static void forceGCStaticMethod() {
72 Runtime.getRuntime().gc();
73 Runtime.getRuntime().gc();
74 Runtime.getRuntime().gc();
75 Runtime.getRuntime().gc();
76 Runtime.getRuntime().gc();
77 Runtime.getRuntime().gc();
78 System.out.println("Forced GC");
79 }
80
81 public static void throwStaticMethod() {
82 throw new Error("Error");
83 }
84}