[OpenJDK 2D-Dev] RFR: 8254024: Enhance native libs for AWT and Swing to work with GraalVM Native Image

Phil Race prr at openjdk.java.net
Wed Dec 9 01:28:34 UTC 2020


On Wed, 9 Dec 2020 00:14:23 GMT, Andrii Rodionov <github.com+1538227+arodionov at openjdk.org> wrote:

> No, we produce only one image. The headless/non-headless mode is defined by the system property `-Djava.awt.headless=...`.
> Here is a command example for native image generation:
> `$ ~/graalvm-ce-java11-21.0.0-dev/bin/native-image -H:ConfigurationFileDirectories=./configs -Djava.awt.headless=true AWTFixExample`
> 
> With `-Djava.awt.headless=false` to the gcc linker we pass `libawt.a` and `libawt_headless.a`
> With `-Djava.awt.headless=true` to the gcc linker we pass `libawt.a` and `libawt-xawt.a`
> If the generated image demands `libmlib_image.a` it will be also linked.

-Djava.awt.headless is a runtime property not a build time property. So you are doing domething very weird.
How does that image with "false" run a UI app ? It can't. And yet the one with "true" still can run without an xserver, except it will not start unless you have X11 libs installed - and I am *reasonably* sure you aren't statically linking all the system provided libraries ... I hope ...

So how does a "user" use all of this ? Seems they must create their own app by native compile + linking.
Can they create an image that can run any java app, or must the app like AWTFixExample be linked in to the image ?

-------------

PR: https://git.openjdk.java.net/jdk/pull/562


More information about the 2d-dev mailing list