JNI: Transforming primitive types

M

Marcelo

Hi everybody,

I would like to know if there is simple way in JNI to pass a float** in c++ to a
jobjectArray.

should I first search the jclass element, then creating the NewObjectArray and
at the end, coping all the c++ float-elements to the jobjectArray?

is there a simplest and low ressource-consuming way?

thanks a lot,

Marcelo
 
G

Gordon Beaton

I would like to know if there is simple way in JNI to pass a float**
in c++ to a jobjectArray.

should I first search the jclass element, then creating the
NewObjectArray and at the end, coping all the c++ float-elements to
the jobjectArray?

is there a simplest and low ressource-consuming way?

Except for the fact that a float array is a more suitable structure
for holding floats than an Object array is, you've described an
appropriate method. What problems are you having?

/gordon
 
M

Marcelo

hi,
my problem is that i don't understad if this senteces is OK:

float *vectA; //Some values inside vectA
....
jfloatArray jarr; //After initialize jarr with float class
....

(*env)->SetIntArrayRegion(env, jarr, 0, 100, vectA);

does it work?

Is there any problem passing floats in c to the jfloats in Java?

Should I do any conversion as we do in Strings?

thanks a lot,

Marcelo
 
G

Gordon Beaton

my problem is that i don't understad if this senteces is OK:

Are you having specific problems, or are you just wondering?

float *vectA; //Some values inside vectA
...
jfloatArray jarr; //After initialize jarr with float class
...

(*env)->SetIntArrayRegion(env, jarr, 0, 100, vectA);

does it work?

Is there any problem passing floats in c to the jfloats in Java?

Should I do any conversion as we do in Strings?

If you want to store floats in a float (not Float) array, pass vectA
to SetFloatArrayRegion (*not* SetIntArrayRegion). Note that float is
not, as you imply, a class.

/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,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top