Principle is the mechanism of using reflection
Examples of reflection in Java:
// Find Class New // methods for finding classes New // methods for executing classes
The C language is the same with the reflection mechanism:
Jclass ( *findclass) (jnienv*, const char*), Jclass clazz= (*env)->findclass (env, "com/example/ndkcallback/ Dataprovider ");// Jmethodid (*getmethodid) (jnienv*, Jclass, const char*, const char*);//method signature Parameters and return Values Jmethodid methodid= (*env)->getmethodid (Env,clazz, "Hellofromjava", "() V");//void (*callvoidmethod) ( jnienv*, Jobject, Jmethodid, ...);( *env)->callvoidmethod (Env,jobject,methodid);
How to get the method signature:
Enter the factory classes directory:
The full path of the C:\users\zy\desktop\workspace\jnitest\bin\classes>javap-s class
So get the method signature
C code in JNI calls Java code