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

Add the dependency to your pom.xml:
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.

notify

wait

Returns true on notification, false on timeout.

close

SharedRegion implements AutoCloseable for try-with-resources:

Complete example

JNA internals

The ZincLib interface maps the C ABI functions:
JNA loads libzinc_core.{so,dylib,dll} 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.