How to create static JNI Environment Pointer?

It's generally unsafe to cache a JNIEnv instance and keep using it, as it varies depending on the currently active thread. You can save a JavaVM instance, which will never change. In a native initializer function, call GetJavaVM and pass it the address of a JavaVM pointer.

It's generally unsafe to cache a JNIEnv* instance and keep using it, as it varies depending on the currently active thread. You can save a JavaVM* instance, which will never change. In a native initializer function, call GetJavaVM and pass it the address of a JavaVM pointer: static JavaVM *jvm; JNIEXPORT void JNICALL Java_SomeClass_init(JNIEnv *env, jclass) { int status = (*env)->GetJavaVM(env, &jvm); if(status!

= 0) { // Fail! } } Now you can use that JavaVM* to get the current JNIEnv* with AttachCurrentThread: dsmResult_t dsmInitializeCall( dsmResult_t status, void * pUserData, dsmEvent_t * hEvent ) { JNIEnv *env; (*jvm)->AttachCurrentThread(jvm, (void **)&env, NULL); (*env)->CallVoidMethod(env, classObject, mid); }.

Stackoverflow. Com/questions/6152747/… – ViTo Brothers Apoyan Jun 1 at 20:04 And why I cant use jclass cls = (*env)->GetObjectClass( env, classObject ); Instead of jclass cls = (*env)->FindClass( env, "com/Dsm/Test/DSMInitializeClassParameter" ); I think that classObject is object to my class in which I have DSMInitializeCallback so I can get class from that object. But when I try application crashed with Dalvic VM Error .... But why?

– ViTo Brothers Apoyan Jun 2 at 5:35 stackoverflow. Com/questions/6184678/… – ViTo Brothers Apoyan Jun 2 at 8:35.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions