1

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??

1
  • i think i found it :Use CallObjectMethod. For example: jmethodID myMethod = (*env)->GetMethodID(myClass, "myMethod", "()[I"); jintArray retval = (jintArray) (*env)->CallObjectMethod(myObject, myMethod); Commented Apr 15, 2013 at 14:51

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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);

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.