Skip to content

Commit

Permalink
Merge pull request #6 from jchalou/jchaloup/native-embedding-doc
Browse files Browse the repository at this point in the history
Add links to the native-embedding C examples.
  • Loading branch information
chumer committed Jan 17, 2024
2 parents 6cac873 + a24802a commit c73f5c2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions native-embedding/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Polyglot Native Embedding Demo with GraalVM for JDK 21
Demonstration project showing polyglot native embedding with GraalVM JDK 21 using Maven.
It contains a simple API class that is built into a native libary and then accessed in a C program.
The C program runs both with the JVM library and the self-contained library built by Native Image
It contains a simple API class that is built into a native libary and then accessed in a few example C programs.
The C programs listed below run both with the JVM library and the self-contained library built by Native Image
as a part of this project.

The project is supported on all platforms where GraalVM is supported.

> On Windows the project has to be executed from the Visual Studio's x64 Native Tools Command Prompt.
* [hello-with-callback.c](./src/test/c/hello-with-callback.c) - print a simple message with a string part obtained from a callback to the C program.
* [fib.c](./src/test/c/fib.c) - compute n-th element of the Fibonacci sequence.
* [evaljs.c](./src/test/c/evaljs.c) - eval a JS string passed as a parameter.

## Setup

Expand All @@ -23,6 +23,10 @@ Download Maven or import as Maven project into your IDE.
* `mvn -Pnative verify` to build the native embedding library by Native Image and run the C tests of the API exposed by the library.
* `mvn -Pnative verify -Dbuild.native.embedding.library.phase=none` to run the C tests without building the library (when the library is already built).

> The project is supported on all platforms where GraalVM is supported.
> On Windows the project has to be executed from the Visual Studio's x64 Native Tools Command Prompt.
### Generating C headers for the native methods in the Java files

The `hello-with-callback` C test requires a helper library to invoke the native callback and the helper library is invoked via the `jumpToCallback` native method defined
Expand Down

0 comments on commit c73f5c2

Please sign in to comment.