Is it ok to save JavaVM * and JNIEnv * as a global variable and use it elsewhere?

自闭症网瘾萝莉.ら 提交于 2019-12-01 09:37:52

Is it ok to save JavaVM * as a global variable and use it elsewhere?

Yes.

Is it ok to save JNIEnv * as a global variable and use it elsewhere?

No. That represents a context for a specific JNI method invocation. It is dependent on the current thread, the arguments to the current method, the local references that have been created by the current method, all sorts of things, and it becomes invalid once that JNI method returns.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!