Hi all - I'm a newb at JNI and I need to write a C function that returns a jdoubleArray. For starters I just wanted to create a new array and fill it with some dummy data. Here's my C code:
#include <jni.h>
#include "MyClass.h"
JNIEXPORT jdoubleArray JNICALL Java_MyClass_myMethod
(JNIEnv *env, jobject obj, jstring str)
{
//create a dummy array to return
jdoubleArray dummy = (*env)->NewDoubleArray(env, 2);
dummy[0] = 0.123;
dummy[1] = 1;
return dummy;
}
When I get the double[] back on the Java side though it contains all zeroes. I'm sure I have a stupid mistake somewhere but can't find it. Any ideas?