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 public Main() { 19 } 20 21 int testThisWithInstanceCall() { 22 return doNativeCallRef(); 23 } 24 25 int testThisWithStaticCall() { 26 return doStaticNativeCallRef(); 27 } 28 29 static int testParameter(Object a) { 30 return doStaticNativeCallRef(); 31 } 32 33 static int testObjectInScope() { 34 Object a = array[0]; 35 return doStaticNativeCallRef(); 36 } 37 38 native int doNativeCallRef(); 39 static native int doStaticNativeCallRef(); 40 41 public static void main(String[] args) { 42 System.loadLibrary(args[0]); 43 Main rm = new Main(); 44 if (rm.testThisWithInstanceCall() != 1) { 45 throw new Error("Expected 1"); 46 } 47 48 if (rm.testThisWithStaticCall() != 2) { 49 throw new Error("Expected 2"); 50 } 51 52 if (testParameter(new Object()) != 3) { 53 throw new Error("Expected 3"); 54 } 55 56 if (testObjectInScope() != 4) { 57 throw new Error("Expected 4"); 58 } 59 } 60 61 static Object[] array = new Object[] { new Object() }; 62 } 63