Skip to content
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

Support for Liberica Native Image #76

Closed
SimonScholz opened this issue Dec 19, 2023 · 8 comments · Fixed by #91
Closed

Support for Liberica Native Image #76

SimonScholz opened this issue Dec 19, 2023 · 8 comments · Fixed by #91
Assignees
Labels
enhancement New feature or request

Comments

@SimonScholz
Copy link

As of now the following distributions are available.

  • graalvm
  • graalvm-community
  • mandrel

Is there any chance that the Liberica Native Image Kit will be added as well?
I do use it to create native images for my tiny Swing application, which works quite well with the Liberica Native Image Kit, but unfortunately not for the other distributions.

@fniephaus
Copy link
Member

Hi @SimonScholz,
there are currently no plans to add Liberica, but it could be done if someone is willing to do the work.

Maybe this is also a use case for #61, which we haven't finished yet.

Your "tiny Swing application" builds fine with Liberica because it provides AWT metadata that happens to work for your app out of the box? Have you considered generating metadata specifically for your application? It should then be possible to build it with any GraalVM distribution, and the binaries may be even smaller. If you select graalvm (Oracle GraalVM), you could even build your app with G1 GC if latency is an issue.

@SimonScholz
Copy link
Author

Have you considered generating metadata specifically for your application? It should then be possible to build it with any GraalVM distribution, and the binaries may be even smaller. If you select graalvm (Oracle GraalVM), you could even build your app with G1 GC if latency is an issue.

Well I already tried really hard with Oracle GraalVM and then gave up until I found Liberica, because I had one issue after another.
I even made the actual native build work with Oracle GraalVM, but then at runtime it always crashed due to missing Fonts, which were not available in the JDK, and problems with the FontManager.
I even tried to set the java.home programmatically, which is for some reason hard coded in the JDK for awt here: https://github.com/SimonScholz/qr-code-with-logo/blob/5ebe2678bd020f20d5286b77a14936835d2f4c39/qr-code-app/src/main/kotlin/io/github/simonscholz/Main.kt#L27

@fniephaus Do you maybe have a working example for the usage of the regular Oracle GraalVM together with Swing/AWT? Then I'd be delighted to try it out and use Oracle GraalVM instead of Liberica.

@fniephaus
Copy link
Member

Well I already tried really hard with Oracle GraalVM and then gave up until I found Liberica, because I had one issue after another.
I even made the actual native build work with Oracle GraalVM, but then at runtime it always crashed due to missing Fonts, which were not available in the JDK, and problems with the FontManager.
I even tried to set the java.home programmatically, which is for some reason hard coded in the JDK for awt here: https://github.com/SimonScholz/qr-code-with-logo/blob/5ebe2678bd020f20d5286b77a14936835d2f4c39/qr-code-app/src/main/kotlin/io/github/simonscholz/Main.kt#L27

I had a quick look at your example application and it seems you've already tried using the tracing agent. I tried running it on my own and immediately ran into something we still need to finish.
I'm surprised to learn that Liberica has somehow solved all those issue for you, but they ship a substantial amount of metadata that is relatively hard to maintain.

Do you maybe have a working example for the usage of the regular Oracle GraalVM together with Swing/AWT?

We currently recommend using the tracing agent, which does not seem to be enough to get your application working. However, we do have plans to improve this in the future. So please stay tuned or get in touch on Slack if you'd like to help :)

@petermz
Copy link
Contributor

petermz commented Jan 24, 2024

I'm going to look into adding Liberica as a new distribution. I'll submit a PR when it is ready.

@fniephaus
Copy link
Member

Maybe you can re-use some of the Mandrel support, for example #67?

@petermz
Copy link
Contributor

petermz commented Jan 26, 2024

I'll definitely need an example to learn from, thanks!

Sorry for a lame question, but I can't wrap my head around dist/main/index.js. Was it generated by some tool? E.g. in const mandrel_1 = __nccwpck_require__(8766);, where does 8766 come from?

@fniephaus
Copy link
Member

You may want to look at the template. The dist/ files are generated from the sources in src/.

@fniephaus
Copy link
Member

Liberica is now available via v1.2.0.

@fniephaus fniephaus added the enhancement New feature or request label Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants