blob: 68a46449f035979c5edcc48b6028cd4fee3498c0 [file] [log] [blame]
Mathieu Chartier1ceb37c2016-08-30 10:23:01 -07001/*
2 * Copyright (C) 2016 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
17public class Main {
18 /// CHECK-START: java.lang.Object Main.newObject() prepare_for_register_allocation (before)
19 /// CHECK: LoadClass
20 /// CHECK: NewInstance
21
22 /// CHECK-START: java.lang.Object Main.newObject() prepare_for_register_allocation (after)
23 /// CHECK-NOT: LoadClass
24 /// CHECK: NewInstance
25 public static Object newObject() {
26 return new Object();
27 }
28
29 /// CHECK-START: java.lang.Object Main.newFinalizableMayThrow() prepare_for_register_allocation (after)
30 /// CHECK: LoadClass
31 /// CHECK: NewInstance
32 public static Object newFinalizableMayThrow() {
33 return $inline$newFinalizableMayThrow();
34 }
35
36 public static Object $inline$newFinalizableMayThrow() {
37 return new FinalizableMayThrow();
38 }
39
40 public static void main(String[] args) {
41 newFinalizableMayThrow();
42 newObject();
43 }
44}
45
46class FinalizableMayThrow {
47 // clinit may throw OOME.
48 static Object o = new Object();
49 static String s;
50 public void finalize() {
51 s = "Test";
52 }
53}