I had to do this recently in a React Native project, and I could not find a way around it without using JNI. To do this, you basically need to make the code for the JS to Java bridge, and then more code for the Java-C bridge (via JNI), and then return to JS.
If you only pass primitives, then this is pretty easy, since JNI can deal with type conversion, like Java int, to jint (which is an int typedef) in C, but if you pass complex data types, then you need to write code, to get the C structure from the JJI job by telling the JNI which fields you have and what types these fields are. It was easier for me to write utility functions for this. This is a lot of initial setup and boring code, but as soon as you go and get used to it, it is not so difficult. JNI Spec is great for reference, it just doesn't tell you how you should use it.
I have a github project that uses JNI to traverse some class classes. This blog article explains all the configuration steps for JNI, and if you're comfortable with it, it gets into the dirty details of βReal World JNI.β Let me know if you have any questions about this.
source share