这个 JNI 代码没有返回值 nbField 的可能原因是什么?
JNIEXPORT jint JNICALL Java_com_morpho_morphosmart_sdk_MorphoDatabaseNative_getNbField
(JNIEnv *i_env, jobject thisObj, jlong morphoDatabasePointerCPP, jobject nbField){
I l_i_Ret;
UL l_ul_NbField;
l_i_Ret = dataBase->GetNbField(l_ul_NbField);
// l_ul_NbField is equal 2 after here
if(l_i_Ret == 0) // l_i_Ret is not null
{
jclass longClass = i_env->GetObjectClass(nbField);
jfieldID val = i_env->GetFieldID(longClass, "value", "J");
if(val == NULL)
return -899;
i_env->SetLongField(nbField, val, (L)l_ul_NbField);
// nbField is an output value wich is expected to have the value 2 after here !
}
return l_i_Ret; }
此代码导致返回 0 但 nbField 为空! Java 调用者
long nbField = 0 ;
int l_i_ret = morphoDatabase.getNbField(nbField);
Log.d("GetNBFields","after getNBFields : "+ nbField + " r : " + l_i_ret );
问题出在这部分代码中, nbField
不返回l_ul_NbField
.