Something like this should work:
jboolean MyJNIMethod(JNIEnv * env, jobject obj, jobjectArray myArray)
{
int len1 = env -> GetArrayLength(myArray);
jfloatArray dim= (jfloatArray)env->GetObjectArrayElement(myArray, 0);
int len2 = env -> GetArrayLength(dim);
float **localArray;
// allocate localArray using len1
localArray = new float*[len1];
for(int i=0; i<len1; ++i){
jfloatArray oneDim= (jfloatArray)env->GetObjectArrayElement(myArray, i);
jfloat *element=env->GetFloatArrayElements(oneDim, 0);
//allocate localArray[i] using len2
localArray[i] = new float[len2];
for(int j=0; j<len2; ++j) {
localArray[i][j]= element[j];
}
}
//TODO play with localArray, don't forget to release memory ;)
}
Note that this is outline. It won't compile ;) (I wrote it in this overstacks' editor)
In your class you should declare native method:
public native void myJNIMethod(float[][] m);
and in your c code corresponding:
JNIEXPORT jboolean JNICALL Java_ClassName_methodName (JNIEnv *, jobject, jobjectArray);
Here is JNI array operations documentation.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…