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

Wildfly fails to compile with latest GraalVM for JDK 22, 24.0.0-dev builds #74

Closed
zakkak opened this issue Oct 25, 2023 · 1 comment · Fixed by #75
Closed

Wildfly fails to compile with latest GraalVM for JDK 22, 24.0.0-dev builds #74

zakkak opened this issue Oct 25, 2023 · 1 comment · Fixed by #75
Assignees

Comments

@zakkak
Copy link

zakkak commented Oct 25, 2023

Creating a native image that depends on wildfly fails with:

Error: Substitution target for org.wildfly.common.Substitutions$Target_GraalDirectives is not loaded. Use field `onlyWith` in the `TargetClass` annotation to make substitution only active when needed.
com.oracle.svm.core.util.UserError$UserException: Substitution target for org.wildfly.common.Substitutions$Target_GraalDirectives is not loaded. Use field `onlyWith` in the `TargetClass` annotation to make substitution only active when needed.
	at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.UserError.abort(UserError.java:73)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.findTargetClass(AnnotationSubstitutionProcessor.java:1098)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.findTargetClass(AnnotationSubstitutionProcessor.java:1047)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.findTargetClass(AnnotationSubstitutionProcessor.java:1043)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.handleClass(AnnotationSubstitutionProcessor.java:375)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.init(AnnotationSubstitutionProcessor.java:353)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.createAnnotationSubstitutionProcessor(NativeImageGenerator.java:1058)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:924)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:595)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:555)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:540)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:722)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.start(NativeImageGeneratorRunner.java:143)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:98)

This is happening because of recent package renaming in GraalVM: oracle/graal#7650 and oracle/graal#7621.

The failing substitutions are located in:

What's the performance impact of these substitutions? Are they still necessary?

If so. the substitutions should be duplicated and made conditional using onlyWith and a BooleanSupplier like the following to check which class is available and substitute accordingly, in order to support both older and newer GraalVM versions:

    private static class JdkGraalCompilerGraalDirectivesPresent implements BooleanSupplier {
        @Override
        public boolean getAsBoolean() {
            try {
                Class.forName("jdk.graal.compiler.api.directives.GraalDirectives");
                return true;
            } catch (ClassNotFoundException e) {
                return false;
            }
        }
    }

To reproduce one needs to build GraalVM from source:

git clone https://github.com/graalvm/mx
git clone https://github.com/oracle/graal
cd graal
../mx/mx fetch-jdk --java-distribution labsjdk-ce-latest
export JAVA_HOME=/path/to/downloaded/labsjdk
../mx/mx --primary-suite-path substratevm --components="Native Image,LibGraal,Truffle SVM Macro" --native-images=native-image,lib:jvmcicompiler build
export GRAALVM_HOME=$(pwd)/sdk/latest_graalvm_home

cc @dmlloyd

@dmlloyd
Copy link
Member

dmlloyd commented Oct 25, 2023

I think they can just be removed. I'll put up a PR.

dmlloyd added a commit to dmlloyd/wildfly-common that referenced this issue Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants