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 #ifndef ART_TEST_TI_AGENT_JNI_BINDER_H_
18 #define ART_TEST_TI_AGENT_JNI_BINDER_H_
19 
20 #include "jni.h"
21 #include "jvmti.h"
22 
23 namespace art {
24 
25 // Find the given classname. First try the implied classloader, then the system classloader,
26 // then use JVMTI to find all classloaders.
27 jclass GetClass(jvmtiEnv* jvmti_env, JNIEnv* env, const char* class_name, jobject class_loader);
28 
29 // Load the class through JNI. Inspect it, find all native methods. Construct the corresponding
30 // mangled name, run dlsym and bind the method.
31 //
32 // This will abort on failure.
33 void BindFunctions(jvmtiEnv* jvmti_env,
34                    JNIEnv* env,
35                    const char* class_name,
36                    jobject class_loader = nullptr);
37 
38 void BindFunctionsOnClass(jvmtiEnv* jvmti_env, JNIEnv* env, jclass klass);
39 
40 }  // namespace art
41 
42 #endif  // ART_TEST_TI_AGENT_JNI_BINDER_H_
43