0
public class MyOpaqueBasedJSONDict implements IMyJSONDict {
private final long _myNativeCPPObj;
...
public IMyJSONDict getMyJSONObj(String keyName) {
long retVal = nativeGetJSOBObject(_myNativeCPPObj,keyName);
return (new MyOpaqueBasedJSONDict(retVal));
}
native implementation
NIEXPORT jlong JNICALL
Java_com_hexample_myndkapplication_MyOpaqueBasedJSONDict_nativeGetJSOBObject(JNIEnv *env,
jobject instance,
jlong myNativeCPPObj,
jstring keyName_) {
const char *keyName = env->GetStringUTFChars(keyName_, 0);
Json::Value* nativeCppJson_ptr = reinterpret_cast<Json::Value*> (myNativeCPPObj);
Json::Value& map = *nativeCppJson_ptr;
Json::Value& jsonVal = map[keyName];
env->ReleaseStringUTFChars(keyName_, keyName);
return (jlong) &jsonVal;
}
我無法理解爲什麼我收到JNI檢測到的錯誤應用:使用無效jobject的0xb4019a80 三月8日至16日:25:56.785 20537-20537/com.hexample.myndkapplication A/art:art/runtime/java_vm_ext.cc:410] from long com.hexample.myndkapplication.MyOpaqueBasedJSONDict.nativeGetJSOBObjectJNI檢測到的錯誤應用:使用無效jobject的
任何線索如何調試ndk中的無效內存錯誤。我對Android和ndk開發很新穎。