javajvmgraalvmgraalvm-native-imagelinkageerror

Can native-image warn about JVM linking errors?


Java classes are linked at runtime meaning that if a class is replaced in an incompatible way, it may result in a Errors when running the application.

For example, let's take the following classes:

public class Main{
    public static void main(String[] args){
        SomeClass.doSomething();
    }
}
public class SomeClass{
    public static void doSomething(){}
}

If we compile both classes together (javac Main.java SomeClass.java) and run Main, it runs successfully.

However, if we modify SomeClass (for whatever reason, it might be a library) and recompiling it without recompiling Main:

public class SomeClass{
    public static void doSomethingNew(){}//name change here
}

we are (as expected) getting a NoSuchMethodError because Main refers to SomeClass. Similarly, we are getting a NoClassDefFoundError if we delete SomeClass.class and just run Main.

However, when using GraalVM's native-image tool, we have a closed-world assumption meaning that used all classes must be known at image build-time and cannot be modified. If classes are incompatible or missing, we are still getting the NoSuchMethodError/NoClassDefFoundError (or similar LinkageErrors) when running the image as this behavior is mandated by the specification:

$ native-image -Ob Main
========================================================================================================================
GraalVM Native Image: Generating 'main' (executable)...
========================================================================================================================
[1/8] Initializing...                                                                                    (2.9s @ 0.11GB)
 Java version: 21.0.2+13-LTS, vendor version: Oracle GraalVM 21.0.2+13.1
 Graal compiler: optimization level: b, target machine: x86-64-v3, PGO: off
 C compiler: gcc (linux, x86_64, 14.2.0)
 Garbage collector: Serial GC (max heap size: 80% of RAM)
 1 user-specific feature(s):
 - com.oracle.svm.thirdparty.gson.GsonFeature
------------------------------------------------------------------------------------------------------------------------
Build resources:
 - 11.27GB of memory (75.6% of 14.92GB system memory, determined at start)
 - 8 thread(s) (100.0% of 8 available processor(s), determined at start)
[2/8] Performing analysis...  [******]                                                                   (8.4s @ 0.19GB)
    2,133 reachable types   (62.1% of    3,437 total)
    2,066 reachable fields  (45.9% of    4,504 total)
   10,042 reachable methods (39.3% of   25,580 total)
      741 types,   112 fields, and   476 methods registered for reflection
       49 types,    34 fields, and    48 methods registered for JNI access
        4 native libraries: dl, pthread, rt, z
[3/8] Building universe...                                                                               (1.3s @ 0.22GB)
[4/8] Parsing methods...      [*]                                                                        (0.9s @ 0.22GB)
[5/8] Inlining methods...     [***]                                                                      (1.0s @ 0.25GB)
[6/8] Compiling methods...    [**]                                                                       (4.9s @ 0.25GB)
[7/8] Layouting methods...    [*]                                                                        (0.7s @ 0.32GB)
[8/8] Creating image...       [*]                                                                        (1.5s @ 0.21GB)
   2.38MB (37.07%) for code area:     5,565 compilation units
   3.61MB (56.37%) for image heap:   58,333 objects and 43 resources
 430.86kB ( 6.56%) for other data
   6.41MB in total
------------------------------------------------------------------------------------------------------------------------
Top 10 origins of code area:                                Top 10 object types in image heap:
   1.26MB java.base                                          733.53kB byte[] for java.lang.String
 930.06kB svm.jar (Native Image)                             696.27kB byte[] for code metadata
  84.88kB com.oracle.svm.svm_enterprise                      390.05kB java.lang.String
  19.45kB org.graalvm.nativeimage.base                       389.10kB heap alignment
  17.37kB jdk.internal.vm.ci                                 339.78kB java.lang.Class
  15.33kB jdk.proxy3                                         157.38kB java.util.HashMap$Node
  14.99kB jdk.proxy1                                         114.01kB char[]
  14.47kB org.graalvm.collections                            102.19kB byte[] for reflection metadata
   4.97kB jdk.internal.vm.compiler                            88.68kB java.lang.Object[]
   3.62kB jdk.proxy2                                          83.32kB com.oracle.svm.core.hub.DynamicHubCompanion
  471.00B for 1 more packages                                605.70kB for 575 more object types
                              Use '-H:+BuildReport' to create a report with more details.
------------------------------------------------------------------------------------------------------------------------
Security report:
 - Binary does not include Java deserialization.
 - Use '--enable-sbom' to embed a Software Bill of Materials (SBOM) in the binary.
------------------------------------------------------------------------------------------------------------------------
Recommendations:
 G1GC: Use the G1 GC ('--gc=G1') for improved latency and throughput.
 PGO:  Use Profile-Guided Optimizations ('--pgo') for improved throughput.
 INIT: Adopt '--strict-image-heap' to prepare for the next GraalVM release.
 HEAP: Set max heap for improved and more predictable memory usage.
 CPU:  Enable more CPU features with '-march=native' for improved performance.
------------------------------------------------------------------------------------------------------------------------
                        1.5s (6.7% of total time) in 101 GCs | Peak RSS: 0.77GB | CPU load: 5.29
------------------------------------------------------------------------------------------------------------------------
Produced artifacts:
 /tmp/y/main (executable)
========================================================================================================================
Finished generating 'main' in 21.9s.
$ ./main 
Exception in thread "main" java.lang.NoSuchMethodError: SomeClass.doSomething()
    at Main.main(Main.java:3)
    at java.base@21.0.2/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)

In the build output, I don't see any mention or warning that some classes are incompatible. I also tried using options like --initialize-at-build-time=Main,SomeClass or --strict-image-heap but this didn't change that behavior.

Is there any possibility (e.g. via CLI options or by implementing custom Features) to let native-image warn me about incompatibilities like that since it has to check for them anyways (for imitating the said LinkageErrors) (maybe I'm just overloooking an option)?
If this is fundamentally not possible with native-image or there are problems with implementing that, what are these issues?


Solution

  • Below command will check all types to be fully defined

    native-image --link-at-build-time -Ob Main
    

    --link-at-build-time: require types to be fully defined at native executable build time. If used without arguments, all classes in scope of the option are required to be fully defined.

    ozkan@hp-envy-2021-i7-nvidia:~/tmp$ native-image  --link-at-build-time -Ob Main
    ========================================================================================================================
    GraalVM Native Image: Generating 'main' (executable)...
    ========================================================================================================================
    [1/8] Initializing...                                                                                    (3.8s @ 0.07GB)
     Java version: 23.0.1+11, vendor version: GraalVM CE 23.0.1+11.1
     Graal compiler: optimization level: b, target machine: x86-64-v3
     C compiler: gcc (linux, x86_64, 13.2.0)
     Garbage collector: Serial GC (max heap size: 80% of RAM)
     1 user-specific feature(s):
     - com.oracle.svm.thirdparty.gson.GsonFeature
    ------------------------------------------------------------------------------------------------------------------------
    Build resources:
     - 5.78GB of memory (75.6% of 7.64GB system memory, determined at start)
     - 8 thread(s) (100.0% of 8 available processor(s), determined at start)
    [2/8] Performing analysis...  [****]                                                                    (18.7s @ 0.33GB)
        3,294 reachable types   (70.7% of    4,662 total)
        3,865 reachable fields  (43.6% of    8,874 total)
       15,492 reachable methods (44.3% of   34,972 total)
        1,029 types,    14 fields, and   138 methods registered for reflection
           57 types,    57 fields, and    52 methods registered for JNI access
            4 native libraries: dl, pthread, rt, z
    
    Error: Aborting stand-alone image build. Discovered unresolved method during parsing: SomeClass.doSomething(). This error is reported at image build time because class Main is registered for linking at image build time by command line and command line.
    Error encountered while parsing com.oracle.svm.core.JavaMainWrapper.invokeMain(JavaMainWrapper.java:169)
    Parsing context:
       at com.oracle.svm.core.JavaMainWrapper.runCore0(JavaMainWrapper.java:232)
       at com.oracle.svm.core.JavaMainWrapper.doRun(JavaMainWrapper.java:299)
       at com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_XNhh1mz2Ib2aPR1wdv014D(generated:0)
       at static root method.(Unknown Source)
    
    Detailed message:
    
    Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Discovered unresolved method during parsing: SomeClass.doSomething(). This error is reported at image build time because class Main is registered for linking at image build time by command line and command line.
    Error encountered while parsing com.oracle.svm.core.JavaMainWrapper.invokeMain(JavaMainWrapper.java:169)
    Parsing context:
       at com.oracle.svm.core.JavaMainWrapper.runCore0(JavaMainWrapper.java:232)
       at com.oracle.svm.core.JavaMainWrapper.doRun(JavaMainWrapper.java:299)
       at com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_XNhh1mz2Ib2aPR1wdv014D(generated:0)
       at static root method.(Unknown Source)
    
    Detailed message:
    
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.constraints.UnsupportedFeatures.report(UnsupportedFeatures.java:126)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:866)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:592)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:554)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:528)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:711)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.start(NativeImageGeneratorRunner.java:139)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:94)
    Caused by: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved method during parsing: SomeClass.doSomething(). This error is reported at image build time because class Main is registered for linking at image build time by command line and command line.
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.reportUnresolvedElement(SharedGraphBuilderPhase.java:604)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.reportUnresolvedElement(SharedGraphBuilderPhase.java:598)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.handleUnresolvedMethod(SharedGraphBuilderPhase.java:525)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.handleUnresolvedInvoke(SharedGraphBuilderPhase.java:411)
            at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.genInvokeStatic(BytecodeParser.java:1857)
            at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.genInvokeStatic(BytecodeParser.java:1836)
            at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5778)
            at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3737)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.iterateBytecodesForBlock(SharedGraphBuilderPhase.java:951)
            at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.handleBytecodeBlock(BytecodeParser.java:3697)
            at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3544)
            at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.build(BytecodeParser.java:1163)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.build(SharedGraphBuilderPhase.java:205)
            at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1055)
            at jdk.graal.compiler/jdk.graal.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:103)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.run(SharedGraphBuilderPhase.java:157)
            at jdk.graal.compiler/jdk.graal.compiler.phases.Phase.run(Phase.java:49)
            at jdk.graal.compiler/jdk.graal.compiler.phases.BasePhase.apply(BasePhase.java:468)
            at jdk.graal.compiler/jdk.graal.compiler.phases.Phase.apply(Phase.java:42)
            at jdk.graal.compiler/jdk.graal.compiler.phases.Phase.apply(Phase.java:38)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.AnalysisParsedGraph.parseBytecode(AnalysisParsedGraph.java:144)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.parseGraph(AnalysisMethod.java:916)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsedHelper(AnalysisMethod.java:881)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsed(AnalysisMethod.java:864)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysisGraphDecoder.lookupEncodedGraph(InlineBeforeAnalysisGraphDecoder.java:181)
            at jdk.graal.compiler/jdk.graal.compiler.replacements.PEGraphDecoder.doInline(PEGraphDecoder.java:1215)
            at jdk.graal.compiler/jdk.graal.compiler.replacements.PEGraphDecoder.tryInline(PEGraphDecoder.java:1198)
            at jdk.graal.compiler/jdk.graal.compiler.replacements.PEGraphDecoder.trySimplifyInvoke(PEGraphDecoder.java:1053)
            at jdk.graal.compiler/jdk.graal.compiler.replacements.PEGraphDecoder.handleInvokeWithCallTarget(PEGraphDecoder.java:1005)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysisGraphDecoder.handleMethodHandle(InlineBeforeAnalysisGraphDecoder.java:298)
            at jdk.graal.compiler/jdk.graal.compiler.nodes.GraphDecoder.processNextNode(GraphDecoder.java:929)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysisGraphDecoder.processNextNode(InlineBeforeAnalysisGraphDecoder.java:269)
            at jdk.graal.compiler/jdk.graal.compiler.nodes.GraphDecoder.decode(GraphDecoder.java:654)
            at jdk.graal.compiler/jdk.graal.compiler.replacements.PEGraphDecoder.decode(PEGraphDecoder.java:895)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysis.decodeGraph(InlineBeforeAnalysis.java:73)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:200)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:652)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.createFlowsGraph(MethodTypeFlow.java:167)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureFlowsGraphCreated(MethodTypeFlow.java:152)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.getOrCreateMethodFlowsGraphInfo(MethodTypeFlow.java:110)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.typestate.DefaultStaticInvokeTypeFlow.lambda$update$0(DefaultStaticInvokeTypeFlow.java:75)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.LightImmutableCollection.forEach(LightImmutableCollection.java:90)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.typestate.DefaultStaticInvokeTypeFlow.update(DefaultStaticInvokeTypeFlow.java:74)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.PointsToAnalysis$1.run(PointsToAnalysis.java:575)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:166)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:152)
            at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1726)
            at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1717)
            at java.base/java.util.concurrent.ForkJoinTask$InterruptibleTask.exec(ForkJoinTask.java:1641)
            at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
            at java.base/java.util.concurrent.ForkJoinPool.externalHelpQuiesce(ForkJoinPool.java:2535)
            at java.base/java.util.concurrent.ForkJoinPool.helpQuiescePool(ForkJoinPool.java:2569)
            at java.base/java.util.concurrent.ForkJoinPool.awaitQuiescence(ForkJoinPool.java:3808)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.complete(CompletionExecutor.java:208)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.PointsToAnalysis.doTypeflow(PointsToAnalysis.java:613)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.PointsToAnalysis.finish(PointsToAnalysis.java:601)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.AbstractAnalysisEngine.runAnalysis(AbstractAnalysisEngine.java:157)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:832)
            ... 6 more
    Caused by: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved method during parsing: SomeClass.doSomething(). This error is reported at image build time because class Main is registered for linking at image build time by command line and command line.
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.reportUnresolvedElement(SharedGraphBuilderPhase.java:604)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.reportUnresolvedElement(SharedGraphBuilderPhase.java:598)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.handleUnresolvedMethod(SharedGraphBuilderPhase.java:525)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.handleUnresolvedInvoke(SharedGraphBuilderPhase.java:411)
            at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.genInvokeStatic(BytecodeParser.java:1857)
            at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.genInvokeStatic(BytecodeParser.java:1836)
            at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5778)
            at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3737)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.iterateBytecodesForBlock(SharedGraphBuilderPhase.java:951)
            at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.handleBytecodeBlock(BytecodeParser.java:3697)
            at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3544)
            at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.build(BytecodeParser.java:1163)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.build(SharedGraphBuilderPhase.java:205)
            at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1055)
            at jdk.graal.compiler/jdk.graal.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:103)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.run(SharedGraphBuilderPhase.java:157)
            at jdk.graal.compiler/jdk.graal.compiler.phases.Phase.run(Phase.java:49)
            at jdk.graal.compiler/jdk.graal.compiler.phases.BasePhase.apply(BasePhase.java:468)
            at jdk.graal.compiler/jdk.graal.compiler.phases.Phase.apply(Phase.java:42)
            at jdk.graal.compiler/jdk.graal.compiler.phases.Phase.apply(Phase.java:38)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.AnalysisParsedGraph.parseBytecode(AnalysisParsedGraph.java:144)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.parseGraph(AnalysisMethod.java:916)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsedHelper(AnalysisMethod.java:881)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsed(AnalysisMethod.java:864)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysisGraphDecoder.lookupEncodedGraph(InlineBeforeAnalysisGraphDecoder.java:181)
            at jdk.graal.compiler/jdk.graal.compiler.replacements.PEGraphDecoder.doInline(PEGraphDecoder.java:1215)
            at jdk.graal.compiler/jdk.graal.compiler.replacements.PEGraphDecoder.tryInline(PEGraphDecoder.java:1198)
            at jdk.graal.compiler/jdk.graal.compiler.replacements.PEGraphDecoder.trySimplifyInvoke(PEGraphDecoder.java:1053)
            at jdk.graal.compiler/jdk.graal.compiler.replacements.PEGraphDecoder.handleInvokeWithCallTarget(PEGraphDecoder.java:1005)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysisGraphDecoder.handleMethodHandle(InlineBeforeAnalysisGraphDecoder.java:298)
            at jdk.graal.compiler/jdk.graal.compiler.nodes.GraphDecoder.processNextNode(GraphDecoder.java:929)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysisGraphDecoder.processNextNode(InlineBeforeAnalysisGraphDecoder.java:269)
            at jdk.graal.compiler/jdk.graal.compiler.nodes.GraphDecoder.decode(GraphDecoder.java:654)
            at jdk.graal.compiler/jdk.graal.compiler.replacements.PEGraphDecoder.decode(PEGraphDecoder.java:895)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysis.decodeGraph(InlineBeforeAnalysis.java:73)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:200)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:652)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.createFlowsGraph(MethodTypeFlow.java:167)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureFlowsGraphCreated(MethodTypeFlow.java:152)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.getOrCreateMethodFlowsGraphInfo(MethodTypeFlow.java:110)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.typestate.DefaultStaticInvokeTypeFlow.lambda$update$0(DefaultStaticInvokeTypeFlow.java:75)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.LightImmutableCollection.forEach(LightImmutableCollection.java:90)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.typestate.DefaultStaticInvokeTypeFlow.update(DefaultStaticInvokeTypeFlow.java:74)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.PointsToAnalysis$1.run(PointsToAnalysis.java:575)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:166)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:152)
            at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1726)
            at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1717)
            at java.base/java.util.concurrent.ForkJoinTask$InterruptibleTask.exec(ForkJoinTask.java:1641)
            at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
            at java.base/java.util.concurrent.ForkJoinPool.externalHelpQuiesce(ForkJoinPool.java:2535)
            at java.base/java.util.concurrent.ForkJoinPool.helpQuiescePool(ForkJoinPool.java:2569)
            at java.base/java.util.concurrent.ForkJoinPool.awaitQuiescence(ForkJoinPool.java:3808)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.complete(CompletionExecutor.java:208)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.PointsToAnalysis.doTypeflow(PointsToAnalysis.java:613)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.PointsToAnalysis.finish(PointsToAnalysis.java:601)
            at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.AbstractAnalysisEngine.runAnalysis(AbstractAnalysisEngine.java:157)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:832)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:592)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:554)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:528)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:711)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.start(NativeImageGeneratorRunner.java:139)
            at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:94)
    ------------------------------------------------------------------------------------------------------------------------
                            1.1s (4.9% of total time) in 191 GCs | Peak RSS: 0.67GB | CPU load: 6.18
    ========================================================================================================================
    Failed generating 'main' after 22.9s.
    Generating fallback image...
    Warning: Image 'main' is a fallback image that requires a JDK for execution (use --no-fallback to suppress fallback image generation and to print more detailed information why a fallback image was necessary).
    ozkan@hp-envy-2021-i7-nvidia:~/tmp$
    

    And if use it with --no-fallback will fail the build, otherwise it generates the main with error throwing NoSuchMethodError.

    native-image --no-fallback --link-at-build-time -Ob Main