Andreas Gampe | e492ae3 | 2016-10-28 19:34:57 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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.Proxy; |
| 18 | import java.util.Arrays; |
| 19 | |
| 20 | public class Main { |
| 21 | public static void main(String[] args) throws Exception { |
| 22 | System.loadLibrary(args[1]); |
| 23 | |
| 24 | doTest(); |
| 25 | } |
| 26 | |
| 27 | public static void doTest() throws Exception { |
| 28 | testClass("java.lang.Object"); |
| 29 | testClass("java.lang.String"); |
| 30 | testClass("java.lang.Math"); |
| 31 | testClass("java.util.List"); |
| 32 | |
| 33 | testClass(getProxyClass()); |
| 34 | |
| 35 | testClass(int.class); |
| 36 | testClass(double[].class); |
| 37 | } |
| 38 | |
| 39 | private static Class<?> proxyClass = null; |
| 40 | |
| 41 | private static Class<?> getProxyClass() throws Exception { |
| 42 | if (proxyClass != null) { |
| 43 | return proxyClass; |
| 44 | } |
| 45 | |
| 46 | proxyClass = Proxy.getProxyClass(Main.class.getClassLoader(), new Class[] { Runnable.class }); |
| 47 | return proxyClass; |
| 48 | } |
| 49 | |
| 50 | private static void testClass(String className) throws Exception { |
| 51 | Class<?> base = Class.forName(className); |
| 52 | testClass(base); |
| 53 | } |
| 54 | |
| 55 | private static void testClass(Class<?> base) throws Exception { |
| 56 | String[] result = getClassSignature(base); |
| 57 | System.out.println(Arrays.toString(result)); |
| 58 | } |
| 59 | |
| 60 | private static native String[] getClassSignature(Class<?> c); |
| 61 | } |