blob: e8ff6a479980c6185f1a81a33898811cb2db6651 [file] [log] [blame]
Guillaume "Vermeille" Sanchez9099ef72015-05-20 15:19:21 +01001/*
2 * Copyright (C) 2015 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 {
David Brazdila06d66a2015-05-28 11:14:54 +010018 /// CHECK-START: void Main.InstanceOfPreChecked(java.lang.Object) instruction_simplifier (after)
19 /// CHECK: InstanceOf must_do_null_check:false
Guillaume "Vermeille" Sanchez9099ef72015-05-20 15:19:21 +010020 public void InstanceOfPreChecked(Object o) throws Exception {
21 o.toString();
22 if (o instanceof Main) {
23 throw new Exception();
24 }
25 }
26
David Brazdila06d66a2015-05-28 11:14:54 +010027 /// CHECK-START: void Main.InstanceOf(java.lang.Object) instruction_simplifier (after)
28 /// CHECK: InstanceOf must_do_null_check:true
Guillaume "Vermeille" Sanchez9099ef72015-05-20 15:19:21 +010029 public void InstanceOf(Object o) throws Exception {
30 if (o instanceof Main) {
31 throw new Exception();
32 }
33 }
34
David Brazdila06d66a2015-05-28 11:14:54 +010035 /// CHECK-START: void Main.CheckCastPreChecked(java.lang.Object) instruction_simplifier (after)
36 /// CHECK: CheckCast must_do_null_check:false
Guillaume "Vermeille" Sanchez9099ef72015-05-20 15:19:21 +010037 public void CheckCastPreChecked(Object o) {
38 o.toString();
Guillaume "Vermeille" Sancheze918d382015-06-03 15:32:41 +010039 ((Main)o).$noinline$Bar();
Guillaume "Vermeille" Sanchez9099ef72015-05-20 15:19:21 +010040 }
41
David Brazdila06d66a2015-05-28 11:14:54 +010042 /// CHECK-START: void Main.CheckCast(java.lang.Object) instruction_simplifier (after)
43 /// CHECK: CheckCast must_do_null_check:true
Guillaume "Vermeille" Sanchez9099ef72015-05-20 15:19:21 +010044 public void CheckCast(Object o) {
Guillaume "Vermeille" Sancheze918d382015-06-03 15:32:41 +010045 ((Main)o).$noinline$Bar();
Guillaume "Vermeille" Sanchez9099ef72015-05-20 15:19:21 +010046 }
47
Guillaume "Vermeille" Sancheze918d382015-06-03 15:32:41 +010048 void $noinline$Bar() {throw new RuntimeException();}
Guillaume "Vermeille" Sanchez9099ef72015-05-20 15:19:21 +010049
50 public static void main(String[] sa) {
51 Main t = new Main();
52 }
53}