Guillaume "Vermeille" Sanchez | 9099ef7 | 2015-05-20 15:19:21 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | public class Main { |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 18 | /// CHECK-START: void Main.InstanceOfPreChecked(java.lang.Object) instruction_simplifier (after) |
| 19 | /// CHECK: InstanceOf must_do_null_check:false |
Guillaume "Vermeille" Sanchez | 9099ef7 | 2015-05-20 15:19:21 +0100 | [diff] [blame] | 20 | public void InstanceOfPreChecked(Object o) throws Exception { |
| 21 | o.toString(); |
| 22 | if (o instanceof Main) { |
| 23 | throw new Exception(); |
| 24 | } |
| 25 | } |
| 26 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 27 | /// CHECK-START: void Main.InstanceOf(java.lang.Object) instruction_simplifier (after) |
| 28 | /// CHECK: InstanceOf must_do_null_check:true |
Guillaume "Vermeille" Sanchez | 9099ef7 | 2015-05-20 15:19:21 +0100 | [diff] [blame] | 29 | public void InstanceOf(Object o) throws Exception { |
| 30 | if (o instanceof Main) { |
| 31 | throw new Exception(); |
| 32 | } |
| 33 | } |
| 34 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 35 | /// CHECK-START: void Main.CheckCastPreChecked(java.lang.Object) instruction_simplifier (after) |
| 36 | /// CHECK: CheckCast must_do_null_check:false |
Guillaume "Vermeille" Sanchez | 9099ef7 | 2015-05-20 15:19:21 +0100 | [diff] [blame] | 37 | public void CheckCastPreChecked(Object o) { |
| 38 | o.toString(); |
Guillaume "Vermeille" Sanchez | e918d38 | 2015-06-03 15:32:41 +0100 | [diff] [blame] | 39 | ((Main)o).$noinline$Bar(); |
Guillaume "Vermeille" Sanchez | 9099ef7 | 2015-05-20 15:19:21 +0100 | [diff] [blame] | 40 | } |
| 41 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 42 | /// CHECK-START: void Main.CheckCast(java.lang.Object) instruction_simplifier (after) |
| 43 | /// CHECK: CheckCast must_do_null_check:true |
Guillaume "Vermeille" Sanchez | 9099ef7 | 2015-05-20 15:19:21 +0100 | [diff] [blame] | 44 | public void CheckCast(Object o) { |
Guillaume "Vermeille" Sanchez | e918d38 | 2015-06-03 15:32:41 +0100 | [diff] [blame] | 45 | ((Main)o).$noinline$Bar(); |
Guillaume "Vermeille" Sanchez | 9099ef7 | 2015-05-20 15:19:21 +0100 | [diff] [blame] | 46 | } |
| 47 | |
Guillaume "Vermeille" Sanchez | e918d38 | 2015-06-03 15:32:41 +0100 | [diff] [blame] | 48 | void $noinline$Bar() {throw new RuntimeException();} |
Guillaume "Vermeille" Sanchez | 9099ef7 | 2015-05-20 15:19:21 +0100 | [diff] [blame] | 49 | |
| 50 | public static void main(String[] sa) { |
| 51 | Main t = new Main(); |
| 52 | } |
| 53 | } |