H
HappyHippy
Hi,
I have a native method which gets an Integer object as a parameter. I
want to create a new Integer object in the method's C/C++ implementation
and return it through the same parameter.
The code I wrote (it actually fails to return data) looks like this:
JNIEXPORT jboolean JNICALL
Java_Java2NativeEngineInterface_startRecognitionNB(JNIEnv *env, jclass,
jobject nHandle)
{
int hResHndl;
if(sr_startRecognition_nb(&hResHndl) != 0)
return false;
jclass objClass = env->GetObjectClass(nHandle);
jmethodID methodId = env->GetMethodID(objClass, "<init>", "(I)V");
if(methodId == 0)
return false;
//This doesn't work... nHandle does not get assigned to a newly
created object
nHandle = env->NewObject(objClass, methodId, hResHndl);
return true;
}
Is there any way to make nHandle point to a new object?
Thank you!
I have a native method which gets an Integer object as a parameter. I
want to create a new Integer object in the method's C/C++ implementation
and return it through the same parameter.
The code I wrote (it actually fails to return data) looks like this:
JNIEXPORT jboolean JNICALL
Java_Java2NativeEngineInterface_startRecognitionNB(JNIEnv *env, jclass,
jobject nHandle)
{
int hResHndl;
if(sr_startRecognition_nb(&hResHndl) != 0)
return false;
jclass objClass = env->GetObjectClass(nHandle);
jmethodID methodId = env->GetMethodID(objClass, "<init>", "(I)V");
if(methodId == 0)
return false;
//This doesn't work... nHandle does not get assigned to a newly
created object
nHandle = env->NewObject(objClass, methodId, hResHndl);
return true;
}
Is there any way to make nHandle point to a new object?
Thank you!