-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trouble using Jansi with GraalVM native-image on MacOS #199
Comments
Do you think you could provide a PR that would provide the needed json files ? |
Might take me a little while, but I'll try to put one together for you. |
Spent some time trying to get this working with graalvm to no success. I tested with For reference, when I ran the graalvm
{
"resources":{
"includes":[
{"pattern":"\\QMETA-INF/maven/org.fusesource.jansi/jansi/pom.properties\\E"},
{"pattern":"\\Qorg/fusesource/jansi/internal/native/Linux/x86_64/libjansi.so\\E"}
]},
"bundles":[]
}
When running a graalvm native-image using these configs jansi does not work, with the following error printed.
|
Further information |
With 2cf4461, I've been able to compile jansi jar to native using GraalVM CE 21.1.0 and run it successfully on OSX. I haven't had any needs for the delayed initialisation. I'll give it a try on the latest GraalVM to be sure. |
@gnodet FYI I'm hitting this with Jansi
For now I haven't been able to apply the fix above and if I use I'll report if I find out more. |
Ah, using According to https://medium.com/graalvm/updates-on-class-initialization-in-graalvm-native-image-generation-c61faca461f7, libraries can be shipped with these these command line options in native-image.properties files. |
Also, I see
If it's possible to move that and other similar initializations to non static blocks, that might also work. |
Still getting the same error on CI builds though:
|
@xtaixe Any chance you are building a statically linked image in your CI builds? If so, see #246 on why you may be seeing this error. |
@rsenden yes, that is correct. I recently discovered this was happening when static linking, but didn't have time to investigate further. |
Looks like there was already some work done to address issue #162, but that doesn't seem to quite do everything that was required in my case to get things working with Jansi in a GraalVM native image.
The problem was that native-image build was running the code that finds and links the necessary native library image at build time, so the library was not linked at run time, resulting in an UnsatisfiedLinkError error at runtime:
I was able to overcome this by telling the native image that the relevant classes must be initialised at runtime rather than at build time. I achieved this by adding the following class to my codebase:
It may be possible to add the necessary configuration (either this file, or appropriate
.json
config files) to the Jansi library itself so that it will work correctly "out of the box" with native-image builds on GraalVM. If not, perhaps this will at least be useful to someone else who encounters the same problem.The text was updated successfully, but these errors were encountered: