IBM User Guide for Java V7 on Windows > Troubleshooting and support > Using diagnostic tools > Using the Reliability, Availability, and Serviceability Interface > Preparing to use JVMRI
Writing an agent
This piece of code demonstrates how to write a very simple JVMRI agent.
When an agent is loaded by the JVM, the first thing that gets called is the entry point routine JVM_OnLoad(). Therefore, your agent must have a routine called JVM_OnLoad(). This routine then must obtain a pointer to the JVMRI function table. This is done by making a call to the GetEnv() function.
/* jvmri - jvmri agent source file. */ #include "jni.h" #include "jvmri.h" DgRasInterface *jvmri_intf = NULL; JNIEXPORT jint JNICALL JVM_OnLoad(JavaVM *vm, char *options, void *reserved) { int rc; JNIEnv *env; /* * Get a pointer to the JNIEnv */ rc = (*vm)->GetEnv(vm, (void **)&env, JNI_VERSION_1_4); if (rc != JNI_OK) { fprintf(stderr, "RASplugin001 Return code %d obtaining JNIEnv\n", rc); fflush(stderr); return JNI_ERR; } /* * Get a pointer to the JVMRI function table */ rc = (*vm)->GetEnv(vm, (void **)&jvmri_intf, JVMRAS_VERSION_1_5); if (rc != JNI_OK) { fprintf(stderr, "RASplugin002 Return code %d obtaining DgRasInterface\n", rc); fflush(stderr); return JNI_ERR; } /* * Now a pointer to the function table has been obtained we can make calls to any * of the functions in that table. */ ......................................................... return rc;}
Parent: Preparing to use JVMRI
Error 404 - Not Found Error 404 - Not Found
The document you are looking for may have been removed or re-named. Please contact the web site owner for further assistance.