jvm :: JavaVM :: attach_current_thread
JniEnv
# Attach the calling thread to the JVM and return its `JniEnv`
fun attach_current_thread: JniEnv import jni_error `{
JNIEnv *env;
#ifdef ANDROID
// the signature is different (better actually) on Android
int res = (*self)->AttachCurrentThread(self, &env, NULL);
#else
int res = (*self)->AttachCurrentThread(self, (void**)&env, NULL);
#endif
if (res != JNI_OK) {
JavaVM_jni_error(NULL, "Could not attach current thread to Java VM", res);
return NULL;
}
return env;
`}
lib/jvm/jvm.nit:188,2--202,3