I wanted to know how would I communicate with the jvmti agent I attached on a running JVM using attach API. When I say communicate ,here\'s what I meant : I want to call native
You could try to register native methods using the JNI. I haven't tested this yet, but you might try something like this:
Add a native method to the class that is supposed to communicate with your JVMTI agent:
public native MyResponseType myNativeMethod (MyRequestType obj);
Then use the JNI to bind this Java method to some method of your JVMTI agent:
static JNINativeMethod methods[] = {
{"myNativeMethod", "(Lmy/package/MyRequestType;)Lmy/package/MyResponseType;", (void *)&native_method}
};
jni->RegisterNatives(cls, methods, 1);
where cls
is a jclass reference to the class containing your native method.