#include "NativeSumDemo.h" JNIEXPORT jdouble JNICALL Java_NativeSumDemo_sum (JNIEnv *env, jclass cls, jdoubleArray arr) { jdouble sum = 0; jsize len = env->GetArrayLength( arr ); // Get the elements; don't care to know if copied or not jdouble *a = env->GetDoubleArrayElements( arr, NULL ); for( jint i = 0; i < len; i++ ) sum += a[ i ]; // Release elements; no need to flush back env->ReleaseDoubleArrayElements( arr, a, JNI_ABORT ); return sum; }