Closed helins closed 1 year ago
Hi @helins. Please try running the native image tracing agent in case you have not. Otherwise, it will be very useful getting a reproducer for this issue because the error log is not giving enough information. I read that you cannot share your project, but please share a smaller program which run same nio function and results in the same error.
Here is the result of running the tracing agent on an uber jar and reproducing the steps that would produce the aforementioned exception if done on a native image: native-agent-tracing-agent.zip
I can try to make a simplified build accessible. However it's not trivial: it's a Clojure code base requiring Clojure tooling with build scripts written for Babashka. I'm afraid you'll most likely spend way too much time just setting up the repo. Maybe I can be more helpful if you indicate me what would you like to inspect?
Good news, turns out it was due to the selector being initialized in a static {}
block in a class silently initialized at build time. When initialized at run time, it seems to work properly.
Describe the issue
Initially, a native image of a Clojure program was behaving very well. After integrating a Java library doing some networking with NIO, the image now fails at runtime when a client tries connecting to a server through TCP. Precisely, when
.wakeup
is called on ajava.nio.channels.Selector
. See exception below.No such problem occurs when running the uberjar used to creating the image.
Steps to reproduce the issue
Unfortunately the setup is complex and part of the codebase cannot be disclosed.
Describe GraalVM and your environment:
More details
Exception:
Building the image: