Question

I am not much aware about JNI environment and stuck here. From Java layer to JNI, it is passing double[][] and double[] as an parameter, How can convert these into C's double*.

Any one have any suggestion?

Was it helpful?

Solution

I got it answer here:

JNIEXPORT void JNICALL Java_JavaArrayTest
(JNIEnv *env, jobject, jdoubleArray x, jdoubleArray y)
{ 
     long N        = env->GetArrayLength(x);           // Access the array length

     double* xPtr  = env->GetDoubleArrayElements(x,0); // Get C++ pointer to array data 
     double* yPtr  = env->GetDoubleArrayElements(y,0); // and "pin" array elements

     - - - - - -
}

Where O/1 defined as :

#define JNI_FALSE 0
#define JNI_TRUE 1
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top