Does micronaut supports JNI. our requirement is like from micronaut app we need to communicate to embedded c/cpp. Can someone pls let me know if its possible or any Reference will help. Thanks in advance
This Micronaut thing is just a Java framework. Presumably you are talking about its "native image" capabilities, that are derived from using it together with GraalVM.
The GraalVM documentation says JNI is supported, with the following caveats:
Individual classes, methods, and fields that should be accessible via JNI must be specified during native image generation in a configuration file. This is similar to how you would make classes available for reflection. Alternatively you can use the JNIRuntimeAccess#register
interface to register classes and fields at analysis time.
Loading JNI implementations is similar to a JVM: GraalVM can look up native implementations using the JNI name mangling scheme in all loaded libraries. Alternatively you can use the registerNatives
JNI function to skip name mangling.
Finally, the documentation states that GraalVM sometimes elides monitors built in to objects if it can prove they are not used in Java code. If you use MonitorEnter
and MonitorExit
on objects it will "fall back on a slower mechanism which uses a map to store lock associations, which itself needs synchronization". They suggest doing the synchronization from Java so the analyzer sees it.