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.Constructor;
18 import java.lang.reflect.Method;
19 
20 public class Main {
21     static final String DEX_FILE = System.getenv("DEX_LOCATION") + "/636-wrong-static-access-ex.jar";
22 
main(String[] args)23     public static void main(String[] args) throws Exception {
24         System.loadLibrary(args[0]);
25         Class<?> pathClassLoader = Class.forName("dalvik.system.PathClassLoader");
26         if (pathClassLoader == null) {
27             throw new AssertionError("Couldn't find path class loader class");
28         }
29         Constructor<?> constructor =
30             pathClassLoader.getDeclaredConstructor(String.class, ClassLoader.class);
31         ClassLoader loader = (ClassLoader) constructor.newInstance(
32             DEX_FILE, ClassLoader.getSystemClassLoader());
33         Class<?> foo = loader.loadClass("Foo");
34         Method doTest = foo.getDeclaredMethod("doTest");
35         doTest.invoke(null);
36     }
37 
ensureJitCompiled(Class<?> cls, String methodName)38     public static native void ensureJitCompiled(Class<?> cls, String methodName);
39 }
40