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

[native-image], GraphicsEnvironment getAllFonts with --initialize-at-build-time= results in linker errors / Unsatisfied links #3416

Closed
Karm opened this issue May 17, 2021 · 2 comments
Assignees

Comments

@Karm
Copy link
Contributor

Karm commented May 17, 2021

Describe the issue
The following code, Main.java:

import java.awt.Font;
import java.awt.GraphicsEnvironment;

public class Main {
    public static void main(String[] args) {
        for (Font font : GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()) {
            System.out.printf("%s, %s\n", font.getFontName(), font.getFamily());
        }
    }
}

compiled as:

export JAVA_HOME=/home/karm/tmp/graal-labsjava11-build;export GRAALVM_HOME=${JAVA_HOME};export PATH=${JAVA_HOME}/bin:${PATH}
javac Main.java
java -agentlib:native-image-agent=config-output-dir=./META-INF/native-image Main
native-image --no-fallback --initialize-at-build-time= -H:DeadlockWatchdogInterval=2 --native-image-info --verbose Main

produces either an occasional deadlock on my system, see deadlock log or it crashes later during the build on undefined reference to `Java_sun_font_Freetype*, see log.

Describe GraalVM and your environment:

  • GraalVM version master 40b6448, 21.1 CE
  • JDK major version: 11
  • Labs JDK: labsjdk-ce-11.0.11-jvmci-21.2-b01-debug
  • OS: Centos 8
  • Architecture: AMD64
  • gcc 8.3.1 redhat
  • relevant system libs: freetype-2.9.1, harfbuzz-1.7.5, fontconfig-2.13.1
@munishchouhan
Copy link
Contributor

@Karm thanks for the contribution
we will check it out and get back to you

@christianwimmer
Copy link

See also the discussion on #3417 for more details.

Summary: Initializing all classes at image build time for AWT/Swing is not feasible at this time. It would require quite extensive patching of the JDK code, which cannot be done in a maintainable way using substitutions. The only proper way would be to make changes to the JDK itself, i.e., contribute to OpenJDK.
Since there is no need to use --initialize-at-build-time=, removing that from the native-image command line is the recommended solution for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants