Skip to content

[GR-18218] Full support for the Foreign Function & Memory API in Native Image #8113

Open
@fniephaus

Description

@fniephaus

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

Metadata

Metadata

Assignees

Type

No type

Projects

Status

In Progress

Status

In progress

Relationships

None yet

Development

No branches or pull requests

Issue actions