Skip to content

Add hegel-jna: a JNA-backed artifact supporting Java 17+ - #19

Merged
esauro merged 2 commits into
mainfrom
support-older-java-versions
Aug 28, 2026
Merged

Add hegel-jna: a JNA-backed artifact supporting Java 17+#19
esauro merged 2 commits into
mainfrom
support-older-java-versions

Conversation

@esauro

@esauro esauro commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Split the build into two published artifacts that share one API and one source tree:

  • dev.hegel:hegel — the existing FFM binding, unchanged for users (Java 22+, Automatic-Module-Name dev.hegel).
  • dev.hegel:hegel-jna — a new JNA binding (Java 17+), with net.java.dev.jna:jna as its only dependency.
Details To make the binding seam backend-neutral, opaque engine handles now cross the Libhegel interface as raw addresses (long, 0 = NULL) instead of MemorySegment; RealLibhegel wraps/unwraps at the FFI boundary and FakeLibhegel no longer touches java.lang.foreign. Each module supplies a package-private LibhegelBackend.open(Path) that Engine calls without knowing which backend it got.

The backend-neutral sources and tests move to shared/, compiled into both jars via build-helper add-source, so the whole behaviour suite runs against both bindings (242 tests on FFM, 241 on JNA, 100% instruction+branch coverage per module). JnaLibhegel maps C bool as byte and size_t as long (the bundled natives are all 64-bit), passes date/time structs by value, and holds each run's output callback strongly until runFree.

Build and tooling follow the multi-module layout: hegel-parent pom, per-module natives fetch and jacoco gates, a test-jna CI job proving the artifact runs on JDK 17 and 21, release.py bumping all three poms and verifying both artifacts on Central, and README/CLAUDE.md docs. Surefire now passes --enable-native-access=ALL-UNNAMED in both modules (JNA triggers the JDK 24+ JEP 472 warning too). The shared suite's one Java-21 construct (record patterns in ConformanceTest) is rewritten for 17, and the Nd-category assertion tolerates codepoints newer than the running JVM's Unicode tables.

Co-Authored-By: Claude Fable 5 noreply@anthropic.com

esauro and others added 2 commits August 28, 2026 11:47
Split the build into two published artifacts that share one API and one
source tree:

- dev.hegel:hegel — the existing FFM binding, unchanged for users
  (Java 22+, Automatic-Module-Name dev.hegel).
- dev.hegel:hegel-jna — a new JNA binding (Java 17+), with
  net.java.dev.jna:jna as its only dependency.

To make the binding seam backend-neutral, opaque engine handles now
cross the Libhegel interface as raw addresses (long, 0 = NULL) instead
of MemorySegment; RealLibhegel wraps/unwraps at the FFI boundary and
FakeLibhegel no longer touches java.lang.foreign. Each module supplies
a package-private LibhegelBackend.open(Path) that Engine calls without
knowing which backend it got.

The backend-neutral sources and tests move to shared/, compiled into
both jars via build-helper add-source, so the whole behaviour suite
runs against both bindings (242 tests on FFM, 241 on JNA, 100%
instruction+branch coverage per module). JnaLibhegel maps C bool as
byte and size_t as long (the bundled natives are all 64-bit), passes
date/time structs by value, and holds each run's output callback
strongly until runFree.

Build and tooling follow the multi-module layout: hegel-parent pom,
per-module natives fetch and jacoco gates, a test-jna CI job proving
the artifact runs on JDK 17 and 21, release.py bumping all three poms
and verifying both artifacts on Central, and README/CLAUDE.md docs.
Surefire now passes --enable-native-access=ALL-UNNAMED in both modules
(JNA triggers the JDK 24+ JEP 472 warning too). The shared suite's one
Java-21 construct (record patterns in ConformanceTest) is rewritten for
17, and the Nd-category assertion tolerates codepoints newer than the
running JVM's Unicode tables.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@esauro
esauro merged commit 4531533 into main Aug 28, 2026
10 checks passed
@esauro
esauro deleted the support-older-java-versions branch August 28, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant