Project Panama - Foreign Function & Memory API #JVMLS

preview_player
Показать описание
Presented by Maurizio Cimadamore - Compiler Architect (Java Platform Group - Oracle) during the JVM Language Summit 2023 (Santa Clara CA).

Try the preview FFM API in JDK 21

Prepare for the final FFM API in JDK 22

Generate FFM binding with the jextract tool

Build the latest version of the FFM API & jextract

More information on Panama

Tags: #ProjectPanama #Java #JVMLS #OpenJDK
Рекомендации по теме
Комментарии
Автор

I was pleasantly surprised by the ease of use of preview version of FFM api in JDK20 with a fairly large C library. The jextract makes it quite straightforward. The only challenge I faced was with double pointers (i.e. passing address of pointer to C functions).

SourabhBhat
Автор

definitely useful for all kinds of Databases and Big data tools built in all JVM languages

piyushkatariya
Автор

In all these examples, it's the java program that starts first and call native functions. Is there any provision in Panama for incorporating a jvm into a native program? Something like the old JNI invocation API, which, if i remember correctly, is still kind of buggy?

msx
Автор

This sounds good in practice, I'm using it with a C library, and it's pretty good...
But there are downsides compared to JNI that are not explained here, it's not all sunshines and roses. It is limited to C, everything else is unclear. I mean, JExtract for sure works only with C headers, what I don't understand is whether the API can work with C++/Rust/Others libraries.
With Rust, it's even more complicated. Rust doesn't have headers, so to generate one it's needed the usage of 'cbindgen' which requires functions to be written/annotated in a certain way in order to be exposed. So, for C++/Rust, the only way is to create wrappers? But then JNI is much easier in such situations, so, what's the point of Panama exactly?
I'd really appreciate it if anyone from the Project Panama team could shed some light on my doubts

Like, I understand that those languages are much more complicated than C. But in the next releases JNI usage is going to be restricted, because we are meant to use the new half backed FFM API? If JNI can do more, and more easily even, what's exactly the point of Panama

Edit: great, I just found out another flaw of this API. Long on Windows and Linux have different sizes, which makes any MemoryLayout which has longs dependent on the OS. Screw the 'compile once run everywhere' I guess

CraccaHacka
Автор

I hope it will not take so many years until the release 1.0

alcarsharif
Автор

GA or GTFO! Much love ❤ no hate but please hurry

zmitrokz