#include static jvmtiEnv* jvmti; JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) { (*vm)->GetEnv(vm, (void**)&jvmti, JVMTI_VERSION_1_0); return JNI_VERSION_1_6; } JNIEXPORT void JNICALL Java_SlowJvmti_registerMethodIDs(JNIEnv* env, jclass self, jclass cls) { jint method_count; jmethodID* methods; if ((*jvmti)->GetClassMethods(jvmti, cls, &method_count, &methods) == 0) { (*jvmti)->Deallocate(jvmti, (unsigned char*)methods); } } JNIEXPORT jlong JNICALL Java_SlowJvmti_getMethodID(JNIEnv* env, jclass self, jobject method) { return (jlong)(*env)->FromReflectedMethod(env, method); } JNIEXPORT jclass JNICALL Java_SlowJvmti_getMethodDeclaringClass(JNIEnv* env, jclass self, jlong methodID) { jclass holder; (*jvmti)->GetMethodDeclaringClass(jvmti, (jmethodID)methodID, &holder); return holder; }