blob: 4031ff1fb8dac14032baf4c4ef6c1c857d6e7ff2 [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);
29 }
30
31 public static void $opt$TestInvokeStatic() {
32 printStaticMethod();
Nicolas Geoffray4a34a422014-04-03 10:38:37 +010033 printStaticMethodWith2Args(1, 2);
34 printStaticMethodWith5Args(1, 2, 3, 4, 5);
35 printStaticMethodWith7Args(1, 2, 3, 4, 5, 6, 7);
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +000036 forceGCStaticMethod();
37 throwStaticMethod();
38 }
39
40 public static void printStaticMethod() {
41 System.out.println("In static method");
42 }
43
Nicolas Geoffray4a34a422014-04-03 10:38:37 +010044 public static void printStaticMethodWith2Args(int a, int b) {
45 System.out.println("In static method with 2 args " + a + " " + b);
46 }
47
48 public static void printStaticMethodWith5Args(int a, int b, int c, int d, int e) {
49 System.out.println("In static method with 5 args "
50 + a + " " + b + " " + c + " " + d + " " + e);
51 }
52
53 public static void printStaticMethodWith7Args(int a, int b, int c, int d, int e, int f, int g) {
54 System.out.println("In static method with 7 args "
55 + a + " " + b + " " + c + " " + d + " " + e + " " + f + " " + g);
56 }
57
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +000058 public static void forceGCStaticMethod() {
59 Runtime.getRuntime().gc();
60 Runtime.getRuntime().gc();
61 Runtime.getRuntime().gc();
62 Runtime.getRuntime().gc();
63 Runtime.getRuntime().gc();
64 Runtime.getRuntime().gc();
65 System.out.println("Forced GC");
66 }
67
68 public static void throwStaticMethod() {
69 throw new Error("Error");
70 }
71}