Skip to content

[native-image] UserException thrown when Version is used from a substitution class  #1889

Description

@gwenneg

Hi GraalVM team!

I tried to replace System.getProperty("org.graalvm.version").startsWith("19.2.") with Version.getCurrent().compareTo(19, 3) < 0 in a class similar to this one:

@TargetClass(value = Field.class, onlyWith = GraalVersion19_2.class)
final class FieldReplacement {
    // Content omitted
}

final class GraalVersion19_2 implements BooleanSupplier {
    public boolean getAsBoolean() {
        return Version.getCurrent().compareTo(19, 3) < 0;
    }
}

The following exception was then thrown during the native image generation:

Error: ImageSingletons do not contain key org.graalvm.home.HomeFinder
com.oracle.svm.core.util.UserError$UserException: ImageSingletons do not contain key org.graalvm.home.HomeFinder
	at com.oracle.svm.core.util.UserError.abort(UserError.java:65)
	at com.oracle.svm.hosted.ImageSingletonsSupportImpl$HostedManagement.doLookup(ImageSingletonsSupportImpl.java:119)
	at com.oracle.svm.hosted.ImageSingletonsSupportImpl.lookup(ImageSingletonsSupportImpl.java:44)
	at org.graalvm.nativeimage.ImageSingletons.lookup(ImageSingletons.java:86)
	at org.graalvm.home.HomeFinder.getInstance(HomeFinder.java:99)
	at org.graalvm.home.Version.getCurrent(Version.java:293)
	at io.quarkus.runtime.graal.GraalVersion19_2.getAsBoolean(FieldReplacement.java:62)
	at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.findTargetClass(AnnotationSubstitutionProcessor.java:806)
	at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.handleClass(AnnotationSubstitutionProcessor.java:252)
	at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.init(AnnotationSubstitutionProcessor.java:230)
	at com.oracle.svm.hosted.NativeImageGenerator.createDeclarativeSubstitutionProcessor(NativeImageGenerator.java:876)
	at com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:825)
	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:528)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:445)
	at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Error: Image build request failed with exit status 1

Is that an expected behavior?

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions