Skip to content

Instantly share code, notes, and snippets.

@rmpestano
Last active April 9, 2020 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmpestano/defff304bd68de1cb2a095838a11fe07 to your computer and use it in GitHub Desktop.
Save rmpestano/defff304bd68de1cb2a095838a11fe07 to your computer and use it in GitHub Desktop.
Skip method handles
  • quarkus: 1.3.2
  • graalvm: 20.0.0
  • jdk11:
    @BuildStep
    void registerRuntimeInitialization(BuildProducer<RuntimeInitializedClassBuildItem> runtimeInitClassBuildItem)
    {
        runtimeInitClassBuildItem.produce(
                new RuntimeInitializedClassBuildItem(MethodHandleBeanELResolver.class.getCanonicalName()));
        runtimeInitClassBuildItem.produce(
                new RuntimeInitializedClassBuildItem(MethodHandleMetadataTargetImpl.class.getCanonicalName()));
        runtimeInitClassBuildItem.produce(
                new RuntimeInitializedClassBuildItem(MethodHandleUtils.class.getCanonicalName()));
    }

Following is native image build output, including the exception:

[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on GraalVM Version 20.0.0 CE
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] /Users/rpestano/opt/graalvm-ce-java11-20.0.0/Contents/Home/bin/native-image -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=1 -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true -J-Duser.language=en -J-Dfile.encoding=US-ASCII --initialize-at-build-time= -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime -H:+JNI -jar quarkus-myfaces-showcase-1.0-SNAPSHOT-runner.jar -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:-AddAllCharsets -H:-IncludeAllTimeZones -H:EnableURLProtocols=http --no-server -H:-UseServiceLoaderFeature -H:+StackTrace quarkus-myfaces-showcase-1.0-SNAPSHOT-runner
[quarkus-myfaces-showcase-1.0-SNAPSHOT-runner:44979]    classlist:  12,073.20 ms,  1.85 GB
[quarkus-myfaces-showcase-1.0-SNAPSHOT-runner:44979]        (cap):   1,721.52 ms,  1.85 GB
[quarkus-myfaces-showcase-1.0-SNAPSHOT-runner:44979]        setup:   3,083.44 ms,  1.85 GB
13:31:49,319 INFO  [org.apa.myf.web.MyFacesContainerInitializer] Using org.apache.myfaces.webapp.MyFacesContainerInitializer
13:31:49,689 INFO  [org.apa.myf.uti.ExternalSpecifications] MyFaces Core Bean Validation support disabled
13:31:49,707 INFO  [org.apa.myf.uti.ExternalSpecifications] MyFaces Core CDI support enabled
13:31:49,708 INFO  [org.apa.myf.uti.ExternalSpecifications] MyFaces Core EL 3.0 support enabled
13:31:49,708 INFO  [org.apa.myf.uti.ExternalSpecifications] MyFaces Core Servlet 4.0 support enabled
13:31:49,734 INFO  [org.pri.web.PostConstructApplicationEventListener] Running on PrimeFaces 8.0
13:31:49,736 INFO  [io.und.web.jsr] UT026005: Adding programmatic server endpoint class org.apache.myfaces.push.EndpointImpl for path /javax.faces.push/{channel}
13:31:49,737 WARNING [org.apa.myf.web.AbstractFacesInitializer] 

********************************************************************
*** WARNING: Apache MyFaces Core is running in DEVELOPMENT mode. ***
***                                            ^^^^^^^^^^^       ***
*** Do NOT deploy to your live server(s) without changing this.  ***
*** See Application#getProjectStage() for more information.      ***
********************************************************************


13:31:49,737 INFO  [org.apa.myf.web.StartupServletContextListener] MyFaces Core has started, it took [407] ms.
13:31:50,583 INFO  [org.jbo.threads] JBoss Threads version 3.0.1.Final
[quarkus-myfaces-showcase-1.0-SNAPSHOT-runner:44979]   (typeflow): 370,773.11 ms, 12.80 GB
[quarkus-myfaces-showcase-1.0-SNAPSHOT-runner:44979]    (objects): 228,170.80 ms, 12.80 GB
[quarkus-myfaces-showcase-1.0-SNAPSHOT-runner:44979]   (features):   5,648.71 ms, 12.80 GB
[quarkus-myfaces-showcase-1.0-SNAPSHOT-runner:44979]     analysis: 632,528.64 ms, 12.80 GB
Error: Unsupported features in 6 methods
Detailed message:
Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Invoke with MethodHandle argument could not be reduced to at most a single call or single field access. The method handle must be a compile time constant, e.g., be loaded from a `static final` field. Method that contains the method handle invocation: java.lang.invoke.MethodHandle.invokeBasic()
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The error is then reported at run time when the invoke is executed.
Trace: 
        at parsing java.lang.invoke.Invokers$Holder.invokeExact_MT(Invokers$Holder)
Call path from entry point to java.lang.invoke.Invokers$Holder.invokeExact_MT(Object, Object): 
        at java.lang.invoke.Invokers$Holder.invokeExact_MT(Invokers$Holder)
        at org.apache.myfaces.util.lang.MethodHandleUtils.getLambdaPropertyDescriptors(MethodHandleUtils.java:113)
        at org.apache.myfaces.el.resolver.MethodHandleBeanELResolver.lambda$getPropertyDescriptor$0(MethodHandleBeanELResolver.java:133)
        at org.apache.myfaces.el.resolver.MethodHandleBeanELResolver$$Lambda$1261/0x00000007c265d840.apply(Unknown Source)
        at sun.security.ec.XECParameters$1.get(XECParameters.java:183)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.initializeLazyValue(SystemPropertiesSupport.java:190)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.getProperty(SystemPropertiesSupport.java:143)
        at com.oracle.svm.core.jdk.Target_java_lang_System.getProperty(JavaLangSubstitutions.java:340)
        at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_ARRAY:Ljava_lang_System_2_0002egetProperty_00028Ljava_lang_String_2_00029Ljava_lang_String_2(generated:0)
Error: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported method java.lang.invoke.MethodHandleNatives.clearCallSiteContext(MethodHandleNatives$CallSiteContext) is reachable
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
Trace: 
        at parsing java.lang.invoke.MethodHandleNatives$CallSiteContext.run(MethodHandleNatives.java:92)
Call path from entry point to java.lang.invoke.MethodHandleNatives$CallSiteContext.run(): 
        at java.lang.invoke.MethodHandleNatives$CallSiteContext.run(MethodHandleNatives.java:92)
        at com.oracle.svm.core.jdk.RuntimeSupport.executeHooks(RuntimeSupport.java:144)
        at com.oracle.svm.core.jdk.RuntimeSupport.executeStartupHooks(RuntimeSupport.java:89)
        at com.oracle.svm.core.JavaMainWrapper.runCore(JavaMainWrapper.java:143)
        at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:186)
        at com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0)
Error: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported type java.lang.invoke.MemberName is reachable: All methods from java.lang.invoke should have been replaced during image building.
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
Trace: 

@rmpestano
Copy link
Author

Using the flag --report-unsupported-elements-at-runtime makes we pass the analysis phase but we still fail during image generation:

[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on GraalVM Version 20.0.0 CE
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] /Users/rpestano/opt/graalvm-ce-java11-20.0.0/Contents/Home/bin/native-image -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=1 -J-Duser.language=en -J-Dfile.encoding=US-ASCII --report-unsupported-elements-at-runtime --initialize-at-build-time= -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime -H:+JNI -jar quarkus-myfaces-showcase-1.0-SNAPSHOT-runner.jar -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:-AddAllCharsets -H:-IncludeAllTimeZones -H:EnableURLProtocols=http --no-server -H:-UseServiceLoaderFeature -H:+StackTrace quarkus-myfaces-showcase-1.0-SNAPSHOT-runner
[quarkus-myfaces-showcase-1.0-SNAPSHOT-runner:47552]    classlist:  10,260.60 ms,  1.44 GB
[quarkus-myfaces-showcase-1.0-SNAPSHOT-runner:47552]        (cap):   1,576.22 ms,  1.44 GB
[quarkus-myfaces-showcase-1.0-SNAPSHOT-runner:47552]        setup:   2,927.18 ms,  1.44 GB
14:27:11,979 INFO  [org.apa.myf.web.MyFacesContainerInitializer] Using org.apache.myfaces.webapp.MyFacesContainerInitializer
14:27:12,390 INFO  [org.apa.myf.uti.ExternalSpecifications] MyFaces Core Bean Validation support disabled
14:27:12,406 INFO  [org.apa.myf.uti.ExternalSpecifications] MyFaces Core CDI support enabled
14:27:12,406 INFO  [org.apa.myf.uti.ExternalSpecifications] MyFaces Core EL 3.0 support enabled
14:27:12,407 INFO  [org.apa.myf.uti.ExternalSpecifications] MyFaces Core Servlet 4.0 support enabled
14:27:12,433 INFO  [org.pri.web.PostConstructApplicationEventListener] Running on PrimeFaces 8.0
14:27:12,434 INFO  [io.und.web.jsr] UT026005: Adding programmatic server endpoint class org.apache.myfaces.push.EndpointImpl for path /javax.faces.push/{channel}
14:27:12,435 WARNING [org.apa.myf.web.AbstractFacesInitializer] 

********************************************************************
*** WARNING: Apache MyFaces Core is running in DEVELOPMENT mode. ***
***                                            ^^^^^^^^^^^       ***
*** Do NOT deploy to your live server(s) without changing this.  ***
*** See Application#getProjectStage() for more information.      ***
********************************************************************


14:27:12,435 INFO  [org.apa.myf.web.StartupServletContextListener] MyFaces Core has started, it took [452] ms.
14:27:13,327 INFO  [org.jbo.threads] JBoss Threads version 3.0.1.Final
[quarkus-myfaces-showcase-1.0-SNAPSHOT-runner:47552]   (typeflow): 529,673.60 ms, 12.80 GB
[quarkus-myfaces-showcase-1.0-SNAPSHOT-runner:47552]    (objects): 231,534.85 ms, 12.80 GB
[quarkus-myfaces-showcase-1.0-SNAPSHOT-runner:47552]   (features):  17,307.14 ms, 12.80 GB
[quarkus-myfaces-showcase-1.0-SNAPSHOT-runner:47552]     analysis: 849,466.71 ms, 12.80 GB
[quarkus-myfaces-showcase-1.0-SNAPSHOT-runner:47552]     (clinit):  13,747.35 ms, 12.80 GB
[quarkus-myfaces-showcase-1.0-SNAPSHOT-runner:47552]     universe:  61,723.00 ms, 12.80 GB
[quarkus-myfaces-showcase-1.0-SNAPSHOT-runner:47552]      (parse):  42,403.69 ms, 12.80 GB
[quarkus-myfaces-showcase-1.0-SNAPSHOT-runner:47552]     (inline):  50,930.80 ms, 12.80 GB
[quarkus-myfaces-showcase-1.0-SNAPSHOT-runner:47552]    (compile):  71,835.77 ms, 12.80 GB
[quarkus-myfaces-showcase-1.0-SNAPSHOT-runner:47552]      compile: 195,821.53 ms, 12.80 GB
[quarkus-myfaces-showcase-1.0-SNAPSHOT-runner:47552]        image:  12,118.57 ms, 12.80 GB
Fatal error: com.oracle.svm.core.util.VMError$HostedError: com.oracle.svm.core.util.UserError$UserException: Static field or an object referenced from a static field changed during native image generation?
  object:java.lang.ref.SoftReference@6c73195b  of class: java.lang.ref.SoftReference
  reachable through:
    object: [Ljava.lang.ref.SoftReference;@228fe9af  of class: java.lang.ref.SoftReference[]
    object: Form(Object,Object,int,Object)void  of class: java.lang.invoke.MethodTypeForm
    object: (MethodHandle,Object,int,Object)void  of class: java.lang.invoke.MethodType
    object: MethodHandle(MethodHandle,Object,int,Object)void  of class: java.lang.invoke.DirectMethodHandle
    object: [Ljava.lang.invoke.MethodHandle;@42e5e45f  of class: java.lang.invoke.MethodHandle[]
    object: Invokers(Object,int,Object)void  of class: java.lang.invoke.Invokers
    object: (Object,int,Object)void  of class: java.lang.invoke.MethodType
    root: java.lang.invoke.MethodHandleImpl$AsVarargsCollector.invokeWithArguments(Object[])

        at com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:70)
        at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:641)
        at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:445)
        at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Caused by: com.oracle.svm.core.util.UserError$UserException: Static field or an object referenced from a static field changed during native image generation?
  object:java.lang.ref.SoftReference@6c73195b  of class: java.lang.ref.SoftReference
  reachable through:
    object: [Ljava.lang.ref.SoftReference;@228fe9af  of class: java.lang.ref.SoftReference[]
    object: Form(Object,Object,int,Object)void  of class: java.lang.invoke.MethodTypeForm
    object: (MethodHandle,Object,int,Object)void  of class: java.lang.invoke.MethodType
    object: MethodHandle(MethodHandle,Object,int,Object)void  of class: java.lang.invoke.DirectMethodHandle
    object: [Ljava.lang.invoke.MethodHandle;@42e5e45f  of class: java.lang.invoke.MethodHandle[]
    object: Invokers(Object,int,Object)void  of class: java.lang.invoke.Invokers
    object: (Object,int,Object)void  of class: java.lang.invoke.MethodType
    root: java.lang.invoke.MethodHandleImpl$AsVarargsCollector.invokeWithArguments(Object[])

        at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
        at com.oracle.svm.hosted.image.NativeImageHeapWriter.verifyTargetDidNotChange(NativeImageHeapWriter.java:129)
        at com.oracle.svm.hosted.image.NativeImageHeapWriter.writeReference(NativeImageHeapWriter.java:157)
        at com.oracle.svm.hosted.image.NativeImageHeapWriter.write(NativeImageHeapWriter.java:146)
        at com.oracle.svm.hosted.image.NativeImageHeapWriter.writeConstant(NativeImageHeapWriter.java:183)
        at com.oracle.svm.hosted.image.NativeImageHeapWriter.writeObject(NativeImageHeapWriter.java:375)
        at com.oracle.svm.hosted.image.NativeImageHeapWriter.writeHeap(NativeImageHeapWriter.java:88)
        at com.oracle.svm.hosted.image.NativeBootImage.build(NativeBootImage.java:472)
        at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:630)
        ... 7 more
Error: Image build request failed with exit status 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  19:21 min
[INFO] Finished at: 2020-04-09T14:45:54+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.3.2.Final:native-image (default) on project quarkus-myfaces-showcase: Failed to generate native image: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR]         [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.lang.RuntimeException: Failed to build native image
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:353)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]         at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[ERROR]         at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:938)
[ERROR]         at io.quarkus.builder.BuildContext.run(BuildContext.java:273)
[ERROR]         at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2027)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1551)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1442)
[ERROR]         at java.base/java.lang.Thread.run(Thread.java:834)
[ERROR]         at org.jboss.threads.JBossThread.run(JBossThread.java:479)
[ERROR] Caused by: java.lang.RuntimeException: Image generation failed. Exit code: 1
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.imageGenerationFailed(NativeImageBuildStep.java:369)
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:339)
[ERROR]         ... 12 more
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

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