blob: a1b1f0c69dd124f3446db6ba7ebab90084fb4396 [file] [log] [blame]
Brian Carlstromce888532013-10-10 00:32:58 -07001/*
2 * Copyright (C) 2013 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
Jeff Hao201803f2013-11-20 18:11:39 -080017import java.lang.reflect.Method;
18
Brian Carlstromce888532013-10-10 00:32:58 -070019class JniTest {
20 public static void main(String[] args) {
21 System.loadLibrary("arttest");
22 testFindClassOnAttachedNativeThread();
Brian Carlstrom67fe2b42013-10-15 18:51:42 -070023 testCallStaticVoidMethodOnSubClass();
Jeff Hao201803f2013-11-20 18:11:39 -080024 testGetMirandaMethod();
Brian Carlstromce888532013-10-10 00:32:58 -070025 }
26
27 private static native void testFindClassOnAttachedNativeThread();
Brian Carlstrom67fe2b42013-10-15 18:51:42 -070028
29 private static void testCallStaticVoidMethodOnSubClass() {
30 testCallStaticVoidMethodOnSubClassNative();
31 if (!testCallStaticVoidMethodOnSubClass_SuperClass.executed) {
32 throw new AssertionError();
33 }
34 }
35
36 private static native void testCallStaticVoidMethodOnSubClassNative();
37
38 private static class testCallStaticVoidMethodOnSubClass_SuperClass {
39 private static boolean executed = false;
40 private static void execute() {
41 executed = true;
42 }
43 }
44
45 private static class testCallStaticVoidMethodOnSubClass_SubClass
46 extends testCallStaticVoidMethodOnSubClass_SuperClass {
47 }
Jeff Hao201803f2013-11-20 18:11:39 -080048
49 private static native Method testGetMirandaMethodNative();
50
51 private static void testGetMirandaMethod() {
52 Method m = testGetMirandaMethodNative();
53 if (m.getDeclaringClass() != testGetMirandaMethod_MirandaInterface.class) {
54 throw new AssertionError();
55 }
56 }
57
58 private static abstract class testGetMirandaMethod_MirandaAbstract implements testGetMirandaMethod_MirandaInterface {
59 public boolean inAbstract() {
60 return true;
61 }
62 }
63
64 private static interface testGetMirandaMethod_MirandaInterface {
65 public boolean inInterface();
66 }
Brian Carlstromce888532013-10-10 00:32:58 -070067}