GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add jextract plugin for code generation by miroswan · Pull Request #17084 · netty/netty

Conversation

@miroswan

@miroswan miroswan commented Jul 10, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Motivation:

Netty's upcoming java.lang.foreign (FFM) transports (starting with kqueue on macOS) need Java bindings to libc and syscalls. jextract can generate those from C headers, but making jextract a build dependency would put a JDK tool on every contributor's and CI build path, and generating at build time makes the output depend on whatever toolchain happens to be installed. We want the generated bindings committed to git, reproducible, and produced without jextract ever being required to build Netty. No existing Netty build step provides a declarative, testable generator with a reproducibility gate around committed generated code.

Modification:

Adds netty5-jextract-maven-plugin (new module, registered in the root <modules>). Its generate goal drives a pre-installed jextract, one invocation per <binding>, and is deliberately not bound to any lifecycle phase, so it runs on demand and the output is committed. Ordinary builds and CI compile the committed sources and never invoke or require jextract.

Key behaviors:

  • Verifies jextract --version against a configured <jextractVersion> and fails on mismatch, so a divergent binary cannot silently produce different sources.
  • Reads the OS SDK's system headers directly (no vendored headers); <functions>/<structs>/... map to jextract --include-* flags. Generation is inherently per-OS.
  • Generates into target/, then prunes the target package and swaps the new tree into src/main/java via an atomic rename, rolling back and preserving the previous tree if the swap fails.
  • Writes a deterministic GENERATED.properties provenance manifest (jextract version, OS, SDK id) beside the sources.
  • Validates configuration up front: duplicate class names, shared struct/union/typedef symbols (which would clobber on disk), blank symbols, and an invalid targetPackage are rejected with actionable messages.

Also adds docs/Jextract.md (plugin usage and the recommended <bindings> layout) and docs/FFM-Build-Strategy.md (how the FFM transport modules will be structured). No FFM transport module is added in this PR.

The plugin targets Java 17 (it runs in Maven's JVM using only ProcessBuilder); the generated bindings and the future transports target Java 25.

Result:

No existing behavior changes: no current module or consumer build path is affected. Netty gains a reproducible, on-demand generator for committed FFM bindings, with jextract required only when regenerating, never to build.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@miroswan
miroswan force-pushed the jextract-maven-plugin branch from 4803ab6 to 2db06f2 Compare July 11, 2026 01:27
@miroswan
miroswan force-pushed the jextract-maven-plugin branch 2 times, most recently from 2b9eecf to e6c25f1 Compare July 27, 2026 06:25
@miroswan
miroswan marked this pull request as ready for review July 27, 2026 06:33
chrisvest
chrisvest reviewed Aug 6, 2026
View reviewed changes

@chrisvest chrisvest left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had some comments

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread docs/FFM-Build-Strategy.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread docs/FFM-Build-Strategy.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread docs/FFM-Build-Strategy.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread docs/FFM-Build-Strategy.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread docs/FFM-Build-Strategy.md Outdated
- Module naming: `transport-ffm-native-kqueue` vs `transport-ffm-bindings-kqueue`.
- JDK gating: profile-skip on JDK < 25 vs. hard-require 25 to build.
- Exact jextract option for pinning the SDK sysroot (may be `SDKROOT` or a clang-arg passthrough
rather than a first-class flag).

@chrisvest chrisvest Aug 6, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what this means.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@miroswan miroswan Aug 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, that was too terse. The intent: for reproducible output jextract must always read a fixed SDK's headers rather than whatever the host happens to resolve. I reworded the bullet to say that plainly and list the candidate mechanisms (SDKROOT, which xcrun and clang honor, or passing -isysroot/--sysroot through jextract's clang argument passthrough, since jextract has no first class flag for it). It stays an open question and is not being solved in this PR.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread jextract-maven-plugin/pom.xml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread jextract-maven-plugin/src/main/java/io/netty/build/jextract/StagingDirectory.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread jextract-maven-plugin/src/main/java/io/netty/build/jextract/BindingValidator.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread jextract-maven-plugin/src/main/java/io/netty/build/jextract/JextractCommand.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread jextract-maven-plugin/src/main/java/io/netty/build/jextract/JextractLocator.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@miroswan
miroswan force-pushed the jextract-maven-plugin branch 3 times, most recently from 0671f78 to ebbc094 Compare August 7, 2026 00:57
chrisvest
chrisvest reviewed Aug 7, 2026
View reviewed changes

@chrisvest chrisvest left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two small things, and then I think it's good.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread jextract-maven-plugin/src/main/java/io/netty/build/jextract/StringUtils.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread jextract-maven-plugin/src/main/java/io/netty/build/jextract/StagingDirectory.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

miroswan added 15 commits August 7, 2026 10:39
@miroswan
Add jextract plugin for code generation
8932135
@miroswan
Use a try-with-resource block for the StagingDirectory resource
7d5c93b
@miroswan
Update jextract plugin Maven API dependencies to latest (3.9.16, 3.15.2)
51b204e
@miroswan
Hard-require Java 25 for FFM modules on 5.0 instead of JDK-gating a p…
087cb3a
…rofile
@miroswan
Trim <className> before passing it to jextract's --header-class-name
23acced
@miroswan
Catch Throwable in StagingDirectory best-effort cleanup so it never f…
aac2f0f
…ails a completed generation
@miroswan
Add StagingDirectoryTest covering promote, rollback, and backup prese…
bbb3686
…rvation
@miroswan
Search for jextract.bat on the PATH when locating jextract on Windows
84fdcb7
@miroswan
Reject generated file-name collisions case-insensitively, including s…
4c3e659
…truct/typedef/union vs header class
@miroswan
Docs: rename FFM common module to netty-native as the single native-a…
8e2769d
…ccess funnel
@miroswan
Docs: clarify enable-native-access names one module on the module pat…
0116f46
…h, ALL-UNNAMED on the classpath
@miroswan
Docs: note Linux libc (glibc vs musl) makes FFM bindings per-OS-and-libc
a8513dd
@miroswan
Docs: clarify the SDK sysroot pinning open question and mark it out o…
8962e95
…f scope for this PR
@miroswan
Use String.isBlank() instead of trim().isEmpty() in StringUtils
df4f058
@miroswan
Catch Throwable on both swap moves so a promotion failure never loses…
0473878
… the committed sources
@miroswan
miroswan force-pushed the jextract-maven-plugin branch from d454f52 to 0473878 Compare August 7, 2026 17:40
@testlens-app

testlens-app Bot commented Aug 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

🚨 TestLens detected 1 failed test 🚨

Here is what you can do:

  1. Inspect the test failures carefully.
  2. If you are convinced that some of the tests are flaky, you can mute them below.
  3. Finally, trigger a rerun by checking the rerun checkbox.

Test Summary

Build PR / windows-x86_64-java25-boringssl > Netty/Handler

Test Runs Flakiness
OpenSslCertificateCompressionTest 🚫 ❌ 0% 🟢

🏷️ Commit: 0473878
▶️ Tests: 218314 executed
⚪️ Checks: 12/12 completed

Test Failures

OpenSslCertificateCompressionTest (Netty/Handler in Build PR / windows-x86_64-java25-boringssl)
java.lang.IllegalStateException: Possible memory leak detected for resource scope 'OpenSslCertificateCompressionTest'. Please use paranoid leak detection to get more information, or set -Dio.netty.util.LeakPresenceDetector.trackCreationStack=true
	at io.netty.util.LeakPresenceDetector$ResourceScope.check(LeakPresenceDetector.java:308)
	at io.netty.util.LeakPresenceDetector$ResourceScope.close(LeakPresenceDetector.java:328)
	at io.netty.util.test.LeakPresenceExtension.afterAll(LeakPresenceExtension.java:140)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:511)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1450)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2019)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)

Muted Tests

Select tests to mute in this pull request:

  • OpenSslCertificateCompressionTest

Reuse successful test results:

  • ♻️ Only rerun the tests that failed or were muted before

Click the checkbox to trigger a rerun:

  • Rerun jobs

Learn more about TestLens at testlens.app.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chrisvest chrisvest added this to the 5.0.0.Final milestone Aug 7, 2026
@chrisvest
chrisvest merged commit ff6a033 into netty:5.0 Aug 7, 2026
12 of 13 checks passed

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@chrisvest chrisvest chrisvest left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

5.0.0.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@miroswan @chrisvest
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.