Home | History | Annotate | Download | only in src
      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 {
     18   /// CHECK-START: void Main.InstanceOfPreChecked(java.lang.Object) instruction_simplifier (after)
     19   /// CHECK:       InstanceOf must_do_null_check:false
     20   public void InstanceOfPreChecked(Object o) throws Exception {
     21     o.toString();
     22     if (o instanceof Main) {
     23       throw new Exception();
     24     }
     25   }
     26 
     27   /// CHECK-START: void Main.InstanceOf(java.lang.Object) instruction_simplifier (after)
     28   /// CHECK:       InstanceOf must_do_null_check:true
     29   public void InstanceOf(Object o) throws Exception {
     30     if (o instanceof Main) {
     31       throw new Exception();
     32     }
     33   }
     34 
     35   /// CHECK-START: void Main.CheckCastPreChecked(java.lang.Object) instruction_simplifier (after)
     36   /// CHECK:       CheckCast must_do_null_check:false
     37   public void CheckCastPreChecked(Object o) {
     38     o.toString();
     39     ((Main)o).$noinline$Bar();
     40   }
     41 
     42   /// CHECK-START: void Main.CheckCast(java.lang.Object) instruction_simplifier (after)
     43   /// CHECK:       CheckCast must_do_null_check:true
     44   public void CheckCast(Object o) {
     45     ((Main)o).$noinline$Bar();
     46   }
     47 
     48   void $noinline$Bar() {throw new RuntimeException();}
     49 
     50   public static void main(String[] sa) {
     51     Main t = new Main();
     52   }
     53 }
     54