< prev index next >

modules/javafx.graphics/src/main/native-glass/gtk/GlassTimer.cpp

Print this page
rev 10015 : 8137141: Fatal error in Method::build_method_counters when called from libglass.so

@@ -77,11 +77,21 @@
     if (context->flag) {
         free(context);
         return FALSE;
     }
     else if (context->runnable) {
-        mainEnv->CallVoidMethod(context->runnable, jRunnableRun, NULL);
-        LOG_EXCEPTION(mainEnv);
+        JNIEnv *env;
+        int envStatus = javaVM->GetEnv((void **)&env, JNI_VERSION_1_6);
+        if (envStatus == JNI_EDETACHED) {
+            javaVM->AttachCurrentThread((void **)&env, NULL);
+        }
+
+        env->CallVoidMethod(context->runnable, jRunnableRun, NULL);
+        LOG_EXCEPTION(env);
+
+        if (envStatus == JNI_EDETACHED) {
+            javaVM->DetachCurrentThread();
+        }
     }
     return TRUE;
 }
 
< prev index next >