#include
#include
#include
#define _JNI_VERSION JNI_VERSION_1_4
#define THREAD_NAME "lib_hello_jni"
JNIEnv *jni_get_env(const char *name);
/* * Pointer to the Java virtual machine * Note: It's okay to use a static variable for the VM pointer since there * can only be one instance of this shared library in a single VM */
static JavaVM *myVm;
static pthread_key_t jni_env_key;
static jobject callback_obj = NULL;
/* * This function is called when a thread attached to the Java VM is canceled or * exited */
static void jni_detach_thread(void *data) {
(*myVm)->DetachCurrentThread(myVm);
}
JNIEnv *jni_get_env(const char *name) {
JNIEnv *env;
env = pthread_getspecific(jni_env_key);
if (env == NULL) {
if ((*myVm)->GetEnv(myVm, (void **) &