I read on on IBM that
To access Java objects\' fields and invoke their methods, native code must make calls to FindClass(), GetFieldID(), GetMethod
For simple case, I use static fields in the C code, initialized with an initId method called from my java classes :
package demo;
public class WithNatives {
static {
initIDs();
}
private static native void initIDs();
}
And in C :
static jmethodID methodId;
void JNICALL Java_demo_WithNatives_initIDs(JNIEnv *env, jclass clazz)
{
// initialize methodId
}