[OpenJDK 2D-Dev] RFR: 8254024: Enhance native libs for AWT and Swing to work with GraalVM Native Image
Andrii Rodionov
github.com+1538227+arodionov at openjdk.java.net
Wed Dec 9 00:17:35 UTC 2020
On Tue, 8 Dec 2020 23:10:08 GMT, Phil Race <prr at openjdk.org> wrote:
>> The following PR fixes https://bugs.openjdk.java.net/browse/JDK-8254024
>>
>> Starting from version 11.0.9, all JDK libraries also build as static libraries (JEP 178: Statically-Linked JNI Libraries).
>> The purpose of using static libraries is to build GraalVM Native image statically linked with Java native libraries, to shipping single executable without runtime dependencies from JRE.
>>
>> For some static libraries, it leads to an issue: if one static library is trying to load another static library in runtime using `dlopen` (and then uses `dlsym` to find symbols). With static libraries, this is not possible and all dynamic calls should be replaced.
>>
>> This happens in `libawt` while it loads `awt-xawt` or `awt_headless` and in `mlib_image`.
>>
>> Current PR fixes this issue for AWT libraries that allow building Swing/AWT applications as a Native image and have no runtime dependencies from JRE.
>
>> This happens in libawt while it loads awt-xawt or awt_headless and in mlib_image.
>
> So I am supposing this means you are producing two different static images ? - either all the time or based on a build flag ?
> One is linking in the X11 lib, the other the headless stub lib ??
>
> Can you confirm that understanding ?
> This of course doesn't scale very well - meaning you are lucky we don't do this more often as you may need more combinations.
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.
-------------
PR: https://git.openjdk.java.net/jdk/pull/562
More information about the 2d-dev
mailing list