Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions docs/docs/experimental/redline.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,28 @@ versions use `redline-runner-jffi-experimental`, which needs only Java 11:
</dependency>
```

If both are present, the Panama runner is used wherever the JDK supports it.
The jffi runner does not bring in [jffi](https://github.com/jnr/jffi) itself, so its version can
follow the rest of your application. Add it next to the runner, together with its native
libraries:

```xml
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jffi</artifactId>
<version>${jffi.version}</version>
</dependency>
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jffi</artifactId>
<version>${jffi.version}</version>
<classifier>native</classifier>
</dependency>
```

Without them, `builder()` fails with `NoClassDefFoundError: com/kenai/jffi/MemoryIO` instead of
falling back.

If both runners are present, the Panama runner is used wherever the JDK supports it.

Your module is then used exactly as it would be without redline:

Expand All @@ -110,7 +131,8 @@ try (var instance = MyModule.builder().build()) {

When native code cannot be used, `builder()` falls back to the bytecode produced by the
[Build Time Compiler](../execution/build-time-compiler.md), which is always generated alongside it.
This happens on platforms outside the table above, or when no runner is on the classpath.
This happens on platforms outside the table above, or when no runner is on the classpath. A jffi
runner without jffi is an error, not a fallback.

Your module keeps working either way, so the fallback is silent. To check which one you got:

Expand Down
15 changes: 13 additions & 2 deletions redline/it/src/it/redline-e2e/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,19 @@
<packaging>jar</packaging>

<dependencies>
<!-- The only dependency a consumer needs. It brings in redline-api (used by
the generated builder), runtime and wasm transitively. -->
<!-- What a consumer needs: jffi, which the runner declares as provided, and the
runner, which brings in redline-api, runtime and wasm transitively. -->
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jffi</artifactId>
<version>@jffi.version@</version>
</dependency>
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jffi</artifactId>
<version>@jffi.version@</version>
<classifier>native</classifier>
</dependency>
<dependency>
<groupId>run.endive</groupId>
<artifactId>redline-runner-jffi-experimental</artifactId>
Expand Down
11 changes: 11 additions & 0 deletions redline/runner-jffi-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
</properties>

<dependencies>
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jffi</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jffi</artifactId>
<classifier>native</classifier>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand Down
7 changes: 1 addition & 6 deletions redline/runner-jffi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
<description>Native code execution via JFFI (Java 11+)</description>

<dependencies>
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jffi</artifactId>
</dependency>
<dependency>
<groupId>run.endive</groupId>
<artifactId>redline-api-experimental</artifactId>
Expand All @@ -37,8 +33,7 @@
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jffi</artifactId>
<classifier>native</classifier>
<scope>runtime</scope>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Loading