Description
TL;DR
Add full support for the Foreign Function & Memory API (JEP 454) to Native Image.
Goals
The Foreign Function & Memory (FFM) API became GA in JDK 22, a new API "by which Java programs can interoperate with code and data outside of the Java runtime."
Since GraalVM for JDK 22, most features of the FFM API are already supported (see release notes). Support for Arena.ofShared
is still experimental and therefore needs to be enabled with option -H:+SharedArenaSupport
at image build time. Full support for the FFM API is ongoing work.
Note that GraalVM for JDK 22 and later support the FFM API on HotSpot (e.g. when Graal is used as a JIT compiler).
As part of #7152 and #7238, we have already added preliminary support for foreign downcalls and an infrastructure to support upcalls in the future. Documentation on what parts of the FFM API work with Native Image and how they can be used can be found here.
Missing Features / Open Tasks
- Shared arenas (i.e.
Arena.ofShared()
) - Improve downcall performance (currently always unoptimized)
- Improve upcall performance (currently always unoptimized)
- Agent support
- Platform support
- missing for Linux AArch64
- missing for Windows AMD64
- missing for MacOS AMD64
- missing for MacOS AArch64
Non-Goals
- It is not a goal to complete the support for the FFM API in time for the release of GraalVM for JDK 22
- It is not a goal to drop support for JNI or the Native Image C API
Related PRs
- [GR-46740] Support JEP 424 ("Panama") foreign down calls in Native Image. #7152
- [GR-47831] Preparations for JEP 424 ("Panama") foreign upcalls in Native Image. #7238
- [GR-49655] Option for experimental Foreign Function and Memory API support. #7980
- [GR-59353] FFM API: Allow upcalls in configuration files. #10168
- [GR-52576] Introduce specialized upcalls for direct method handles. #10235
- [GR-52567] FFM API support for windows-amd64. #10788
- [GR-58659] [GR-58660] Add FFM Support for {darwin,linux}-aarch64 on SubstrateVM #10856
- [GR-61959] SVM: Add shared arena support. #11125
- [GR-63074] Support FFM API on macOS/x64. #11311
- [GR-60208] [GR-52447] Trace FFM API calls in native image agent. #11270
- [GR-63182] [GR-65316] Enable FFM API by default. #11335
Metadata
Metadata
Assignees
Type
Projects
Status
Status