java-native-interfacejniwrapperjnienv

JNI methods with more than one argument?


I am new to JNI and I wanted to pass three integer to the below function

void pauseEffectJNI(unsigned int nSoundId)
    {
        // void pauseEffect(int)

        JniMethodInfo methodInfo;

        if (! getStaticMethodInfo(methodInfo, "pauseEffect", "(I)V"))
        {
            return ;
        }

        methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, (int)nSoundId);
        methodInfo.env->DeleteLocalRef(methodInfo.classID);
    }

Please correct me if I am wrong

What will come in this line if (! getStaticMethodInfo(methodInfo, "pauseEffect", "(I)V"))

(I;I;I)V or just (III)V

if my functions is void pauseEffectJNI(unsigned int nSoundId, unsigned int number1, unsigned int number2) ??

Basically I want to know what if I want to pass more than one Integer

Thanks for the help ... Here is function I made ...COrrect me if i m wrong

  void pauseEffectJNI(unsigned int nSoundId , unsigned int number)
        {
            // void pauseEffect(int)

            JniMethodInfo methodInfo;

            if (! getStaticMethodInfo(methodInfo, "pauseEffect", "(III)V"))
            {
                return ;
            }

            methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, (int)nSoundId,(int) number);
            methodInfo.env->DeleteLocalRef(methodInfo.classID);
        }

Solution

  • Don't try to figure out JNI method signatures by hand, when 'javap -s' will tell you the correct answer with 100% reliability. Use the tools.