Ship native-image metadata for kqueue (macOS/BSD) (#17112) - #17113
Ship native-image metadata for kqueue (macOS/BSD) (#17112)#17113emilienbev wants to merge 1 commit into
Conversation
|
@franz1981 You might be the right reviewer for this one? |
|
/cc @yawkat @vietj @violetagg |
|
Has couchbase signed a corp CLA or does Emilien need to sign an ICLA? |
|
@chrisvest apologies I hadn't done so, I just signed an individual one and represent myself here. |
chrisvest
left a comment
There was a problem hiding this comment.
LGTM but I'll wait to hear from the others before merging.
|
GraalVM team automated the generation of the reachability metadata. Do we want to handle it manually? for example oracle/graalvm-reachability-metadata#9073 |
|
Good point @violetagg, I think this is your call on direction, although it doesn't have to be either/or. I feel stronger towards Netty owning its metadata because adding it here stays consistent with how Netty already handles other parts of the code (there's in-jar metadata for Also the GraalVM repo handles reachability metadata, but it won't cover some gaps (here, the
The same reasoning also applies to the OpenSSL PRs #17131 and netty/netty-tcnative#992 (but I don't mean to drift the conversation here). |
…uated at runtime (netty#17112) Signed-off-by: Emilien Bevierre <emilien.bevierre@couchbase.com>
|
I have a few concerns about hosting it here: it currently lacks automation, tests, and documented knowledge. oracle/graalvm-reachability-metadata already has all three in place, which is worth taking into consideration. |
|
I can tighten the PR to just the parts the graalvm-reachability repo isn't meant for, i.e. keep the Let me know which you prefer and I'll update the PR. |
|
@emilienbev I think when one wants to use the reachability metadata, all metadata provided by the library is ignored. |
🚨 TestLens detected 1 failed test 🚨Here is what you can do:
Test SummaryBuild PR / macos-aarch64-java11-boringssl build > Netty/Transport/Native/KQueue
🏷️ Commit: d9dc03e Test FailuresKQueueETSocketHalfClosedTest > testAllDataReadClosure(TestInfo) (Netty/Transport/Native/KQueue in Build PR / macos-aarch64-java11-boringssl build)Muted TestsSelect tests to mute in this pull request:
Reuse successful test results:
Click the checkbox to trigger a rerun:
Learn more about TestLens at testlens.app. |
|
@violetagg Yes. In our case we don't consume the reachability repo, though we certainly could source from it at build time. Either way we'd still need the run-time inits from For us this particular metadata isn't a big deal, but more generally having native-image metadata ship with each dependency's source spares us downstream projects from hand-maintaining and patching it ourself for every dependency. I'm happy to drop the reachability metadata from this PR if the preferred direction is to leave that to the graalvm repo. My reading of the existing Whichever way you decide, the same applies to the two OpenSSL PRs (#17131 and netty/netty-tcnative#992), so I would adapt those to match. |
|
@violetagg @yawkat @franz1981 thoughts ? |
Motivation
The
netty-transport-classes-kqueue(macOS) module doesn't include GraalVM native-image metadata in META-INF/native-image, while its Linux counterpartnetty-transport-classes-epolldoes.Because of this the kqueue classes default to build-time class initialization under native-image, meaning
KQueue.isAvailable() == trueis baked into the image heap at build-time, which crashes applications at runtime with anUnsatisfiedLinkErrorwhen the package isn't available.Modifications
Added a META-INF/native-image directory for kqueue, similar to epoll:
native-image.properties: added--initialize-at-run-time=io.netty.channel.kqueue,io.netty.channel.unix.Limits,io.netty.channel.unix.IovArray,io.netty.channel.unix.Errors(soKQueue.isAvailable()is evaluated at runtime)resource-config.json: added the kqueue native library (.libnetty_transport_native_kqueue_..jnilib).reflect-config.json/jni-config.json: added reflection/JNI registrations, guarded by typeReachable: io.netty.channel.kqueue.Native.The metadata mirrors epoll's but is adjusted where the two transports differ:
KQueueDomainDatagramChannelregistered in this PR.NativeDatagramPacketArray$NativeDatagramPacketfor JNI, but kqueuehas no such class (it receives datagrams via
DatagramSocketAddressandDomainDatagramSocketAddress, which are both registered, so nothing's needed here)Result
Fixes #17112