The Java Native Interface (JNI) is a feature in the Java Platform that allows Java code to interact with native code written in C. However, this interaction poses risks to the integrity of applications and the Java Platform itself. To address these risks, the Java runtime in JDK NN issues warnings when native code is invoked through JNI. These warnings can be suppressed by enabling native access on the command line. In a future release, invoking native code will result in an error unless native access is explicitly enabled. The goal is to align JNI with the Foreign Function & Memory (FFM) API and restrict the use of JNI to load native libraries and call native code. It is important to note that there are no plans to remove JNI from the Java Platform. The motivations behind these restrictions are the potential for arbitrary undefined behavior, memory corruption, and the circumvention of Java code invariants when using JNI. The FFM API offers a preferred alternative to JNI and mitigates some of these risks. Through these restrictions, the Java runtime aims to achieve integrity by default and prioritize the user experience. Various improvements and features may be added in future releases to further enhance the user experience and provide reliable configuration.
https://openjdk.org/jeps/8307341