1 /* 2 * Copyright (C) 2017 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 import java.lang.reflect.Method; 18 19 public class Main { 20 main(String[] args)21 public static void main(String[] args) { 22 System.loadLibrary(args[0]); 23 24 test(); 25 26 try { 27 if (testCompiled(Main.class.getDeclaredMethod("test"))) { 28 System.out.println("test method successfully verified/compiled."); 29 } else { 30 System.out.println("test method failed to verify/compile."); 31 } 32 } catch (Exception e) { 33 System.out.println("Got unexpected exception: " + e); 34 } 35 } 36 test()37 public static void test() { 38 int[] maybe_null_array = null; 39 for (int i = 0; i < 2; i++) { 40 int[] non_null_array = new int[1]; 41 if (maybe_null_array != null) { 42 i = maybe_null_array[0] + 1; 43 } 44 maybe_null_array = non_null_array; 45 } 46 } 47 testCompiled(Method method)48 public static native boolean testCompiled(Method method); 49 } 50