Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JNI , call boolean method

I got a Java method that get a String and returns boolean.

I call it from JNI like this:

jmethodID function2ID = env->GetMethodID(
                    activityClass,
                    "MyFuncName",
                    "(Ljava/lang/String;)B");
        if ( function2ID == null )
            LOG("Could not find MyFuncName Function")

            jboolean IsAutoPlay =    env->CallBooleanMethod(
                    obj,
                    function2ID,
                    env->NewStringUTF(name));

I get Fatal Signal 11, Any idea what's wrong in the syntax?

like image 262
ibm123 Avatar asked Feb 13 '12 08:02

ibm123


1 Answers

My Java signature was to return Boolean instead of boolean.

Also

jmethodID function2ID = env->GetMethodID(
                    activityClass,
                    "MyFuncName",
                    "(Ljava/lang/String;)B");

needs to be Z instead of B.

jmethodID function2ID = env->GetMethodID(
                    activityClass,
                    "MyFuncName",
                    "(Ljava/lang/String;)Z");
like image 148
ibm123 Avatar answered Sep 19 '22 15:09

ibm123