Fix the way to get the JNI env in java wrapper to prevent crashes when some native threads stop.

This commit is contained in:
Ghislain MARY 2018-06-13 11:24:12 +02:00
parent e2c3e740ec
commit a5dce40387

View file

@ -283,9 +283,8 @@ static inline void handle_possible_java_exception(JNIEnv *env, jobject listener)
{{#callbacks}}
static {{return}} {{callbackName}}({{params}}) {
JNIEnv *env = 0;
jint jvmResult = jvm->AttachCurrentThread(&env,NULL);
if (jvmResult != 0) {
JNIEnv *env = ms_get_jni_env();
if (!env) {
ms_error("cannot attach VM");
return{{returnIfFail}};
}