开发者

JNI Application State

开发者 https://www.devze.com 2022-12-21 03:42 出处:网络
How is state kept when accessing methods t开发者_JS百科hrough JNI? In the example below my Java code is calling the native method drawFromJni, will my native class _nc be persisted between calls?

How is state kept when accessing methods t开发者_JS百科hrough JNI? In the example below my Java code is calling the native method drawFromJni, will my native class _nc be persisted between calls?

If there were better native debugging tools for the NDK this would be pretty easy to find out, but I'm really having problems with the NDK and C++.

extern "C" {
 JNIEXPORT void JNICALL Java_com_jnitest_SurfaceRenderer_drawFromJni(JNIEnv * env, jobject obj);
};

myNativeClass _nc;
JNIEXPORT void JNICALL Java_com_jnitest_SurfaceRenderer_drawFromJni(JNIEnv *  env)
{
     _nc.draw();
}


The implementation of JNI functions follows the scoping rules for the language you're implementing in. If you declare _nc as a global variable (as you've done in your example), it will be shared throughout the entire application.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号