0
我試圖從C傳遞一個字符串到Java,我用以下跟蹤命令重啓,有人可以幫我理解如何解決這個問題嗎?JNI從C傳遞一個字符串到java
PC: 2cf57c7c (__GI_strlen+0xc glibc-2.4/string/strlen.c:42) RA: 2cf202a0 (vfprintf+0x42c0 glibc-2.4/stdio-common/vfprintf.c:1549)
我JNI代碼看起來是這樣的:
JNIEXPORT jstring JNICALL xxx_nativeGetParentName
(JNIEnv *env, jobject obj, jstring childName)
{
log("nativeGetParentName entered\n");
char *name;
Node* parentName = NULL;
jstring jstr = NULL;
name = (char *)(*env)->GetStringUTFChars(env, childName, NULL);
if (name == NULL)
return NULL;
log("about to call mpe_hnGetParentName\n");
int retCode = mpe_GetParentName(name,&parentName); // Call to the C function which holds the implementation
(*env)->ReleaseStringUTFChars(env,childName,name);
if (retCode != 0) {
log("mpe_GetParentName called with return code=%d\n", retCode);
return NULL;
}
if(parentName[0] != NULL) {
jstr= (*env)->NewStringUTF(env, parentName[0]); // Hitting the reboot exactly here!
log("getting ParentName Succeded=%s\n", jstr);
free(parentUuid);
}
return jstr;
}
C函數調用的原型如下:
i32 GetParentName(Node childName, Node **parentName);
節點基本上是一個字符數組:
typedef char[] Node;
我成功地從C方法獲取parentName,但是當我試圖映射到JString時,我正在重新啓動。
在此先感謝!
非常感謝你!我太天真了......那是爲什麼......重新啓動是固定的:)祝你有美好的一天! – user1509665 2012-07-09 05:39:22