Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Returning a jdoubleArray

843829Nov 20 2006 — edited Jun 17 2009
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?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 15 2009
Added on Nov 20 2006
2 comments
848 views