JNI - Getting a double array form Java

E

Edsoncv

Hello
I'm trying (without sucess :( ) to get a double array form Java using
JNI.
My function (in C++) calls "CallDoubleMethod" but put trash in my "C"
double array. I'm doing somethig wrong but I don't know what. I check
the values from Java and it is being calculated perfectly, I think the
problem is in the array association (since I'm not a experienced
programmer). Below is my code.

jdouble *jacj = new jdouble[n];
.....
get class
get method id
get object and so on...

*jacj = env->CallDoubleMethod(res_gradObj, getdataMetID);

I'm almost sure that the problem is in the last line. Can someone
please help me?
Thanks
 
G

Gordon Beaton

I'm trying (without sucess :( ) to get a double array form Java
using JNI. [...]
*jacj = env->CallDoubleMethod(res_gradObj, getdataMetID);

I'm almost sure that the problem is in the last line. Can someone
please help me?

"Array of double" is not a primitive type. Use CallObjectMethod()
instead:

jdoubleArray jacj = CallObjectMethod(...);

/gordon
 
E

Edsoncv

Ok, it worked. Thanks again.!! :)

Gordon said:
I'm trying (without sucess :( ) to get a double array form Java
using JNI. [...]
*jacj = env->CallDoubleMethod(res_gradObj, getdataMetID);

I'm almost sure that the problem is in the last line. Can someone
please help me?

"Array of double" is not a primitive type. Use CallObjectMethod()
instead:

jdoubleArray jacj = CallObjectMethod(...);

/gordon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top