Yes, from C code you can call Java methods. For example, if we want to call the method x.doSomething(5), supposing x is an instance of class MyClass in the "com.example.ndk" package and the method returns void, we can use:
jclass cls = (*env)->FindClass(env, "com/example/ndk/MyClass");
jmethodID mid = (*env)->GetMethodID(env, cls, "doSomething", "(I)V");
(*env)->CallObjectMethod(env, x, mid, 5);
Where:
- "env" is the JNIEnv pointer which you receive in the C JNI method (read here for information about the JNIEnv pointer and native methods).
- "(I)V" is the method signature, which in this case it says that the method has an int parameter (I), and returns void (V).
- "x" is a jobject obtained in some previous *env function (here you can find all of JNI functions pointed by env).