Is it possible to make a callback to a private java method from C++ over JNI? The following piece of code that works if PrivateMethodName
is public does not work if it's private
jobject jobjectRef = env->NewGlobalRef(jobject javaObject);
jclass jobjectClass = env->GetObjectClass(jobjectRef );
jmethodID callbackId = env->GetMethodID(configServiceClass, "PrivateMethodName", "()Ljava/lang/String;");
env->CallObjectMethod(jobjectRef , callbackId )
Edited:
My javaObject belongs to a concrete implementation of an abstract class and the abstract class actually has the private method.I think that's the issue.
I get
2020-07-27 19:12:46.486 2285-2285/com.test.application A/art: art/runtime/java_vm_ext.cc:470] JNI DETECTED ERROR IN APPLICATION: JNI GetMethodID called with pending exception java.lang.NoSuchMethodError: no non-static method "Lcom/test/application/ConcreteClass;.PrivateMethodName()Ljava/lang/String;"