Search code examples
javaandroidjava-native-interfacemultiple-arguments

How to specify variable number of arguments using jni


I have a method in c that is:

static int          callLuaFunctionWithParams(const char *functionName, int numParams, ...);

So it contains a variable number of arguments, and I want to export it so that it could be used on the android app. On the JNIBindings I'm exporting it like:

JNIEXPORT void JNICALL Java_com_example_callLuaFunctionWithParams(JNIEnv* env, jobject obj, jstring functionName, jint numParams, ...);  

but how can I specify that syntax on java

public native void callLuaFunctionWithParams(String functionName, int numParams, ????);

Thanks!


Solution

  • This should works:

    public native void callLuaFunctionWithParams(String functionName, int numParams, Object... params);