由于可能的原因,此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
的值。
答案 0 :(得分:0)
Long nbField = new Long(0);
而不是long
。