Skip to main content
The Java adapter uses JNA (Java Native Access) to call the Zinc C ABI. JNA needs no native glue code. It loads the shared library and maps function calls through its built-in FFI.

Installation

Build the core from a source checkout, then run mvn install in adapters/java. This installs the adapter into your local Maven repository; Maven Central publishing is pending. The source targets Java 17 or later. Add the dependency to your application:
The adapter requires JNA 5.x, which is pulled in as a transitive dependency.

SharedRegion

create

Creates a new region. Throws RuntimeException on failure.

open

Opens an existing region.

buffer

Returns a java.nio.ByteBuffer backed by the shared memory mapping. No copying occurs.
The buffer is direct (backed by native memory). It is writable by default.

signal

waitForNotification

Returns true on notification, false on timeout.

close

SharedRegion implements AutoCloseable for try-with-resources:

Complete example

This uses two handles in one JVM. For separate JVMs, keep the creator running until the reader finishes. tryWait() consumes a pending notification without blocking.

JNA internals

The ZincLib interface maps the C ABI functions:
JNA loads libzinc_core.{so,dylib} through its platform-native library loading mechanism. Ensure the library is on java.library.path or use Native.load with an absolute path. The Pointer.getByteBuffer(offset, length) method creates a direct ByteBuffer wrapping the native memory. The JVM garbage collector does not manage this buffer. It is valid only as long as the region handle is open.