2 ms·
I thought JNI was being deprecated in favor of the new FFM interface. https://openjdk.org/jeps/472 https://openjdk.org/jeps/472
by aeonik 1y ago
I thought JNI was being deprecated in favor of the new FFM interface.
https://openjdk.org/jeps/472 https://openjdk.org/jeps/472
- cogman10 1y agoNotice the delivery version (24). That was literally just sent out in March. The FFM interface was stabilized in 22. 21 is the latest LTS version which is the furthest most orgs will go.
- da_chicken 1y agoThat doesn't mean you should happily go out and build a new cathedral of technical debt.
- immibis 1y agoThis says: > It is not a goal to deprecate JNI or to remove JNI from the Java Platform. It says they want to put a safety barrier in front of JNI, so you'll have to explicitly indicate that you want a module to use JNI.
- aeonik 1y agoI know that's the goal, but I was doing deeper reading and didn't understand the nuances here. It felt deprecated, and I remember reading that you should prefer FFM. That's one of the reasons I posted it. A lot of knowledgeable people here can chime in more details. And a sibling comment did!
- pron 1y agoFFM is the recommended alternative, but JNI is not being deprecated. There are some things that JNI can do that FFM can't, in particular - initiating calls from native code to arbitrary Java methods. FFM only supports upcalls to Java in the form of Java callbacks that are passed to the native code. However, this is enough for the vast majority of Java-native interactions, so FFM should be preferred in new code (it's much easier to use than JNI).