Dev DOS
Dev DOS

Reputation: 1068

return a float array from java to jni

I'm calling a java method from jni.This method return a float[]

   jclass javaClass = env->GetObjectClass(activityObj);
   jmethodID method = env->GetMethodID(javaClass,"findparam", "([FF)F");
   jfloatArray rotateArray = env->CallFloatMethod(activityObj, method, s1, s2);

But when i tried to compile it i had :

   error: cannot convert 'jfloat' to '_jfloatArray*' in initialization

how can i get the returnet float array??

Upvotes: 1

Views: 2599

Answers (3)

Sondes Sassou
Sondes Sassou

Reputation: 48

Just try to use jfloatArray imageArray = (jfloatArray) env->CallObjectMethod(Object,method); It should resolve your problem .

Upvotes: 1

user207421
user207421

Reputation: 310985

CallFloatMethod() is for calling methods that return float. You are calling a method that returns float[]. You should be calling CallObjectMethod().

Upvotes: 0

GooseSerbus
GooseSerbus

Reputation: 1270

All array types (even primitive types) are returned as a jobject which you should then cast to the appropriate j<type>Array type.

So your final line should read:

jfloatArray rotateArray = (jfloatArray)env->CallObjectMethod(activityObj, method, s1, s2);

Upvotes: 0

Related Questions