java - JNINativeInterface_ * is null -
i developing jni application. jninativeinterface_ * inside struct struct jnienv_
null, hence causing call jni (example : env->newstringutf(...)
) functions throw segmentation fault error. jnienv_
struct looks :
struct jnienv_ { const struct jninativeinterface_ *functions; . . .
i dont know how fix this, think java supposed fill when make call system.loadlibrary(...)
. appreciate help.
two possibilities:
1) c++ code called java native function:
for example:
jniexport void jnicall java_myjnative_dosomething(jnienv *env, jobject jo) { std::cout << "dosomething() : "; }
the jnienv*
pointer given java environment.
2) c++ code calls java code via jni:
in case have setup javavm*
, jnienv*
pointer, following jni invocation logic. see example this article.
a special case mentionned, if have invoked jnienv*
work multiple threads on c++ side. every thread has attach jnienv*
using:
jnienv *env; // pointer native interface jint rc = jvm->attachcurrentthread ((void **)&env, nullptr); // attach without addutiobal parameters // jvm valid javavm*
Comments
Post a Comment