0

I have a java method, like this:

public static native void receiveCallback(byte[] value1, byte[] value2);

In JNI I can reach the class and I can reach the method, but my parameter list is incorrect. I am trying to call the method like this:

jmethodID testJavaMethod = (java_environment)->GetMethodID(clazz, "receiveCallback","([B[B");

I then get a NoSuchMethod exception at runtime.

I followed multiple SO questions, including this one JNI - How to callback from C++ or C to Java?, but I'm still stuck.

Any suggestions?

Thanks.

Community
  • 1
  • 1
TooManyEduardos
  • 4,206
  • 7
  • 35
  • 66

1 Answers1

1

If you want to call back into Java, the implementation must be in Java. You need

public static void receiveCallback(byte[] value1, byte[] value2) {
    // do something with value1 and value2
}

And to get the id of a static method you need to use "GetStaticMethodID". Also to call it you will have to use "CallStaticVoidMethod()".

user2543253
  • 2,143
  • 19
  • 20