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 18 public class Main { 19 20 /// CHECK-START: void Main.boundTypeForIfNotNull() builder (after) 21 /// CHECK-DAG: <<Null:l\d+>> NullConstant 22 /// CHECK-DAG: <<Cst5:i\d+>> IntConstant 5 23 /// CHECK-DAG: <<Cst10:i\d+>> IntConstant 10 24 25 /// CHECK-DAG: InvokeVirtual [<<NullCheck:l\d+>>] 26 /// CHECK-DAG: <<NullCheck>> NullCheck [<<LoopPhi:l\d+>>] klass:int[] 27 /// CHECK-DAG: <<LoopPhi>> Phi [<<Null>>,<<MergePhi:l\d+>>] klass:int[] 28 29 /// CHECK-DAG: <<BoundType:l\d+>> BoundType [<<LoopPhi>>] klass:int[] can_be_null:false 30 /// CHECK-DAG: <<LoadClass1:l\d+>> LoadClass 31 /// CHECK-DAG: <<LoadClass2:l\d+>> LoadClass 32 /// CHECK-DAG: <<NewArray10:l\d+>> NewArray [<<LoadClass2>>,<<Cst10>>] klass:int[] 33 /// CHECK-DAG: <<NotNullPhi:l\d+>> Phi [<<BoundType>>,<<NewArray10>>] klass:int[] 34 35 /// CHECK-DAG: <<NewArray5:l\d+>> NewArray [<<LoadClass1>>,<<Cst5>>] klass:int[] 36 /// CHECK-DAG: <<MergePhi>> Phi [<<NewArray5>>,<<NotNullPhi>>] klass:int[] 37 boundTypeForIfNotNull()38 public static void boundTypeForIfNotNull() { 39 int[] array = null; 40 for (int i = -1; i < 10; ++i) { 41 if (array == null) { 42 array = new int[5]; 43 } else { 44 if (i == 5) { 45 array = new int[10]; 46 } 47 array[i] = i; 48 } 49 } 50 array.hashCode(); 51 } 52 main(String[] args)53 public static void main(String[] args) { } 54 } 55