Graal: [native-image] java.lang.ref.SoftReference - Static field or an object referenced from a static field changed during native image generation

Created on 14 Apr 2020  Â·  13Comments  Â·  Source: oracle/graal

Describe the issue
I don't know how to describe this issue. So here is the stack trace and code.

> 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@2a534cf9  of class: java.lang.ref.SoftReference
>   reachable through:
>     object: [Ljava.lang.ref.SoftReference;@24b7339  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;@6bfa6a8e  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:72)
>   at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:649)
>   at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:452)
>   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@2a534cf9  of class: java.lang.ref.SoftReference
>   reachable through:
>     object: [Ljava.lang.ref.SoftReference;@24b7339  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;@6bfa6a8e  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:130)
>   at com.oracle.svm.hosted.image.NativeImageHeapWriter.writeReference(NativeImageHeapWriter.java:158)
>   at com.oracle.svm.hosted.image.NativeImageHeapWriter.write(NativeImageHeapWriter.java:147)
>   at com.oracle.svm.hosted.image.NativeImageHeapWriter.writeConstant(NativeImageHeapWriter.java:184)
>   at com.oracle.svm.hosted.image.NativeImageHeapWriter.writeObject(NativeImageHeapWriter.java:377)
>   at com.oracle.svm.hosted.image.NativeImageHeapWriter.writeHeap(NativeImageHeapWriter.java:89)
>   at com.oracle.svm.hosted.image.NativeBootImage.build(NativeBootImage.java:483)
>   at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:638)
>   ... 7 more
> Error: Image build request failed with exit status 1

Steps to reproduce the issue
Please include both build steps as well as run steps
git clone https://github.com/warrenc5/jain-slee-js.git
./test.sh will run mvn -Pgraal clean install
mvn -Prun builds and runs the program with the graal agent

go.sh is the command as output from the plugin to run native-image directly.
it generates the binary target/jslee-js

Describe GraalVM and your environment:
Using https://github.com/graalvm/graalvm-ce-dev-builds/releases/tag/20.1.0-dev-20200411_0336
Linux leet 5.5.0-1-amd64 #1 SMP Debian 5.5.13-2 (2020-03-30) x86_64 GNU/Linux

wozza@leet:~/work/code/jslee-js$ ./go.sh
Apply jar:file:///home/wozza/work/code/jslee-js/target/jslee-js-1.0.0-SNAPSHOT.jar!/META-INF/native-image/jni-config.json
Apply jar:file:///home/wozza/work/code/jslee-js/target/jslee-js-1.0.0-SNAPSHOT.jar!/META-INF/native-image/reflect-config.json
Apply jar:file:///home/wozza/work/code/jslee-js/target/jslee-js-1.0.0-SNAPSHOT.jar!/META-INF/native-image/resource-config.json
Apply jar:file:///home/wozza/work/code/jslee-js/target/jslee-js-1.0.0-SNAPSHOT.jar!/META-INF/native-image/proxy-config.json
Build on Server(pid: 168995, port: 36155)
SendBuildRequest [
-task=com.oracle.svm.hosted.NativeImageGeneratorRunner
-imagecp
/usr/local/java/graalvm-ce-java11-20.1.0-dev/lib/svm/builder/llvm-wrapper-shadowed.jar:/usr/local/java/graalvm-ce-java11-20.1.0-dev/lib/svm/builder/javacpp-shadowed.jar:/usr/local/java/graalvm-ce-java11-20.1.0-dev/lib/svm/builder/svm.jar:/usr/local/java/graalvm-ce-java11-20.1.0-dev/lib/svm/builder/pointsto.jar:/usr/local/java/graalvm-ce-java11-20.1.0-dev/lib/svm/builder/llvm-platform-specific-shadowed.jar:/usr/local/java/graalvm-ce-java11-20.1.0-dev/lib/svm/builder/objectfile.jar:/usr/local/java/graalvm-ce-java11-20.1.0-dev/lib/svm/builder/svm-llvm.jar:/usr/local/java/graalvm-ce-java11-20.1.0-dev/lib/svm/library-support.jar:/usr/local/java/graalvm-ce-java11-20.1.0-dev/languages/regex/tregex.jar:/usr/local/java/graalvm-ce-java11-20.1.0-dev/languages/js/asm-7.1.jar:/usr/local/java/graalvm-ce-java11-20.1.0-dev/languages/js/asm-analysis-7.1.jar:/usr/local/java/graalvm-ce-java11-20.1.0-dev/languages/js/asm-commons-7.1.jar:/usr/local/java/graalvm-ce-java11-20.1.0-dev/languages/js/asm-tree-7.1.jar:/usr/local/java/graalvm-ce-java11-20.1.0-dev/languages/js/trufflenode.jar:/usr/local/java/graalvm-ce-java11-20.1.0-dev/languages/js/asm-util-7.1.jar:/usr/local/java/graalvm-ce-java11-20.1.0-dev/languages/js/icu4j.jar:/usr/local/java/graalvm-ce-java11-20.1.0-dev/languages/js/graaljs.jar:/home/wozza/.m2/repository/javax/slee/jainslee-api/1.1/jainslee-api-1.1.jar:/home/wozza/.m2/repository/org/jboss/remotingjmx/remoting-jmx/3.0.4.Final/remoting-jmx-3.0.4.Final.jar:/home/wozza/.m2/repository/org/jboss/xnio/xnio-api/3.5.1.Final/xnio-api-3.5.1.Final.jar:/home/wozza/.m2/repository/org/jboss/xnio/xnio-nio/3.5.1.Final/xnio-nio-3.5.1.Final.jar:/home/wozza/.m2/repository/org/wildfly/client/wildfly-client-config/1.0.0.Final/wildfly-client-config-1.0.0.Final.jar:/home/wozza/.m2/repository/org/wildfly/common/wildfly-common/1.2.0.Final/wildfly-common-1.2.0.Final.jar:/home/wozza/.m2/repository/org/wildfly/security/wildfly-elytron/1.1.0.Final/wildfly-elytron-1.1.0.Final.jar:/home/wozza/.m2/repository/org/jboss/remoting/jboss-remoting/5.0.18.Final/jboss-remoting-5.0.18.Final.jar:/home/wozza/.m2/repository/org/jboss/logging/jboss-logging/3.3.0.Final/jboss-logging-3.3.0.Final.jar:/home/wozza/.m2/repository/org/jboss/marshalling/jboss-marshalling-river/2.0.9.Final/jboss-marshalling-river-2.0.9.Final.jar:/home/wozza/.m2/repository/org/jboss/marshalling/jboss-marshalling/2.0.9.Final/jboss-marshalling-2.0.9.Final.jar:/home/wozza/.m2/repository/javax/javaee-api/7.0/javaee-api-7.0.jar:/home/wozza/.m2/repository/com/sun/mail/javax.mail/1.5.0/javax.mail-1.5.0.jar:/home/wozza/.m2/repository/javax/activation/activation/1.1/activation-1.1.jar:/home/wozza/work/code/jslee-js/target/jslee-js-1.0.0-SNAPSHOT.jar
-H:Path=/home/wozza/work/code/jslee-js
-H:+DumpTargetInfo
-H:JNIConfigurationResources=META-INF/native-image/jni-config.json
-H:ReflectionConfigurationResources=META-INF/native-image/reflect-config.json
-H:ResourceConfigurationResources=META-INF/native-image/resource-config.json
-H:DynamicProxyConfigurationResources=META-INF/native-image/proxy-config.json
-H:+ReportUnsupportedElementsAtRuntime
-H:+ReportExceptionStackTraces
-H:Features=com.oracle.svm.truffle.TruffleFeature,org.graalvm.home.HomeFinderFeature
-H:MaxRuntimeCompileMethods=1400
-H:ClassInitialization=org.graalvm.launcher:build_time,com.oracle.truffle:build_time
-H:MaxRuntimeCompileMethods=9000
-H:ClassInitialization=com.oracle.truffle.js:build_time,com.oracle.js.parser:build_time,com.oracle.truffle.trufflenode:build_time,com.oracle.truffle.regex:build_time
-H:ClassInitialization=com.ibm.icu:run_time
-H:ReflectionConfigurationResources=com/oracle/truffle/js/runtime/resources/reflect-config.json
-H:ResourceConfigurationResources=com/oracle/truffle/js/runtime/resources/resource-config.json
-H:Log=registerResource:basic
-H:+PrintClassInitialization
-H:+TraceClassInitialization
-H:+AllowIncompleteClasspath
-H:ClassInitialization=org.jboss.logging.JDKLevel:build_time
-H:ClassInitialization=Proxy.newProxyInstance:run_time
-H:ClassInitialization=org.wildfly.security.ssl.DelegatingSSLContext:run_time
-H:Class=RunScript
-H:Name=jslee-js
-H:FallbackThreshold=0
-H:CLibraryPath=/usr/local/java/graalvm-ce-java11-20.1.0-dev/lib/svm/clibraries/linux-amd64
]
[jslee-js:168995]    classlist:   1,934.82 ms,  5.92 GB
[jslee-js:168995]        (cap):     225.04 ms,  5.92 GB
[jslee-js:168995]        setup:     388.29 ms,  5.92 GB
# Building image for target platform: org.graalvm.nativeimage.Platform$LINUX_AMD64
# Using native toolchain:
#   Name: GNU project C and C++ compiler (gcc)
#   Vendor: linux
#   Version: 9.3.0
#   Target architecture: x86_64
#   Path: /usr/bin/gcc
# Using CLibrary: com.oracle.svm.core.c.libc.GLibc
Printing initializer configuration to /home/wozza/work/code/jslee-js/reports/initializer_configuration_20200415_055845.txt
[thread:224] scope: ForkJoinPool-29-worker-19
  [thread:224] scope: ForkJoinPool-29-worker-19.registerResource
  ServiceLoaderFeature: registerResource: META-INF/services/java.security.Provider
  [thread:224] scope: ForkJoinPool-29-worker-19.registerResource
  ServiceLoaderFeature: registerResource: META-INF/services/java.nio.file.spi.FileSystemProvider
  [thread:224] scope: ForkJoinPool-29-worker-19.registerResource
  ServiceLoaderFeature: registerResource: META-INF/services/com.oracle.truffle.api.TruffleLanguage$Provider
  [thread:224] scope: ForkJoinPool-29-worker-19.registerResource
  ServiceLoaderFeature: registerResource: META-INF/services/com.oracle.truffle.js.runtime.Evaluator
  [thread:224] scope: ForkJoinPool-29-worker-19.registerResource
  Resources have been added by ServiceLoaderFeature. Automatic registration can be disabled with -H:-UseServiceLoaderFeature
Printing initializer configuration to /home/wozza/work/code/jslee-js/reports/initializer_configuration_20200415_055940.txt
  [thread:224] scope: ForkJoinPool-29-worker-19.registerResource
  ServiceLoaderFeature: registerResource: META-INF/services/java.lang.SecurityManager
  [thread:224] scope: ForkJoinPool-29-worker-19.registerResource
  ServiceLoaderFeature: registerResource: META-INF/services/javax.security.sasl.SaslServerFactory
  [thread:224] scope: ForkJoinPool-29-worker-19.registerResource
  ServiceLoaderFeature: registerResource: META-INF/services/javax.management.remote.JMXConnectorProvider
  [thread:224] scope: ForkJoinPool-29-worker-19.registerResource
  ServiceLoaderFeature: registerResource: META-INF/services/javax.security.sasl.SaslClientFactory
  [thread:224] scope: ForkJoinPool-29-worker-19.registerResource
  ServiceLoaderFeature: registerResource: META-INF/services/org.wildfly.security.http.HttpServerAuthenticationMechanismFactory
  [thread:224] scope: ForkJoinPool-29-worker-19.registerResource
  ServiceLoaderFeature: registerResource: META-INF/services/org.jboss.marshalling.ProviderDescriptor
  [thread:224] scope: ForkJoinPool-29-worker-19.registerResource
  Resources have been added by ServiceLoaderFeature. Automatic registration can be disabled with -H:-UseServiceLoaderFeature
  [thread:224] scope: ForkJoinPool-29-worker-19.registerResource
  ServiceLoaderFeature: registerResource: META-INF/services/org.xnio.XnioProvider
  [thread:224] scope: ForkJoinPool-29-worker-19.registerResource
  Resources have been added by ServiceLoaderFeature. Automatic registration can be disabled with -H:-UseServiceLoaderFeature
Printing initializer dependencies to /home/wozza/work/code/jslee-js/reports/initializer_dependencies_20200415_061226.dot
Printing 1011 classes that are considered as safe for build-time initialization to /home/wozza/work/code/jslee-js/reports/safe_classes_20200415_061226.txt
Printing 18090 classes of type BUILD_TIME to /home/wozza/work/code/jslee-js/reports/build_time_classes_20200415_061226.txt
Printing 62 classes of type RERUN to /home/wozza/work/code/jslee-js/reports/rerun_classes_20200415_061226.txt
Printing 1128 classes of type RUN_TIME to /home/wozza/work/code/jslee-js/reports/run_time_classes_20200415_061226.txt
[jslee-js:168995]     (clinit):   1,314.19 ms,  5.69 GB
# Static libraries:
#   ../../../../../../usr/local/java/graalvm-ce-java11-20.1.0-dev/lib/svm/clibraries/linux-amd64/liblibchelper.a
#   ../../../../../../usr/local/java/graalvm-ce-java11-20.1.0-dev/lib/libnet.a
#   ../../../../../../usr/local/java/graalvm-ce-java11-20.1.0-dev/lib/svm/clibraries/linux-amd64/libstrictmath.a
#   ../../../../../../usr/local/java/graalvm-ce-java11-20.1.0-dev/lib/svm/clibraries/linux-amd64/libffi.a
#   ../../../../../../usr/local/java/graalvm-ce-java11-20.1.0-dev/lib/libextnet.a
#   ../../../../../../usr/local/java/graalvm-ce-java11-20.1.0-dev/lib/libnio.a
#   ../../../../../../usr/local/java/graalvm-ce-java11-20.1.0-dev/lib/libjava.a
#   ../../../../../../usr/local/java/graalvm-ce-java11-20.1.0-dev/lib/libsunec.a
#   ../../../../../../usr/local/java/graalvm-ce-java11-20.1.0-dev/lib/svm/clibraries/linux-amd64/libjvm.a
#   ../../../../../../usr/local/java/graalvm-ce-java11-20.1.0-dev/lib/libzip.a
# Other libraries: stdc++,pthread,dl,z,rt
[jslee-js:168995]   (typeflow): 249,510.04 ms,  5.69 GB
[jslee-js:168995]    (objects): 553,727.02 ms,  5.69 GB
[jslee-js:168995]   (features):  12,868.80 ms,  5.69 GB
[jslee-js:168995]     analysis: 822,494.67 ms,  5.69 GB
[jslee-js:168995]     universe:   8,177.17 ms,  5.70 GB
9798 method(s) included for runtime compilation
[jslee-js:168995]      (parse):   6,871.60 ms,  4.25 GB
[jslee-js:168995]     (inline):   9,208.09 ms,  4.90 GB
[jslee-js:168995]    (compile):  34,743.58 ms,  5.85 GB
[jslee-js:168995]      compile:  54,299.08 ms,  5.86 GB
[jslee-js:168995]        image:   6,157.06 ms,  5.61 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@770a56bb  of class: java.lang.ref.SoftReference
  reachable through:
    object: [Ljava.lang.ref.SoftReference;@5824362b  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;@6d62a12d  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:72)
    at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:649)
    at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:452)
    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@770a56bb  of class: java.lang.ref.SoftReference
  reachable through:
    object: [Ljava.lang.ref.SoftReference;@5824362b  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;@6d62a12d  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:130)
    at com.oracle.svm.hosted.image.NativeImageHeapWriter.writeReference(NativeImageHeapWriter.java:158)
    at com.oracle.svm.hosted.image.NativeImageHeapWriter.write(NativeImageHeapWriter.java:147)
    at com.oracle.svm.hosted.image.NativeImageHeapWriter.writeConstant(NativeImageHeapWriter.java:184)
    at com.oracle.svm.hosted.image.NativeImageHeapWriter.writeObject(NativeImageHeapWriter.java:377)
    at com.oracle.svm.hosted.image.NativeImageHeapWriter.writeHeap(NativeImageHeapWriter.java:89)
    at com.oracle.svm.hosted.image.NativeBootImage.build(NativeBootImage.java:483)
    at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:638)
    ... 7 more
Error: Image build request failed with exit status 1
com.oracle.svm.driver.NativeImage$NativeImageError: Image build request failed with exit status 1
    at com.oracle.svm.driver.NativeImage.showError(NativeImage.java:1541)
    at com.oracle.svm.driver.NativeImage.build(NativeImage.java:1299)
    at com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1260)
    at com.oracle.svm.driver.NativeImage.main(NativeImage.java:1219)
    at com.oracle.svm.driver.NativeImage$JDK9Plus.main(NativeImage.java:1722)
bug native-image

Most helpful comment

And some ideas how to debug the underlying issue, i.e., to debug why java.lang.invoke.MethodHandleImpl$AsVarargsCollector.invokeWithArguments is reachable:
You can use the option -H:+PrintAnalysisCallTree to dump the entire call graph.
Or use the option -H:ReportAnalysisForbiddenType=java.lang.invoke.MethodHandleImpl$AsVarargsCollector to disallow that type completely and then see where the analysis fails.

All 13 comments

I was able to get the image to build with these native-image arguments

--initialize-at-build-time=java.lang.ref.SoftReference
--initialize-at-build-time=java.lang.invoke.MethodHandleImpl

If this is not a bug.. Happy for you to close this :)
Thanks Graal Team!!!

Ran into this one as well with 20.0.0

Ran into this as well but the arguments above didn't resolve it.

The fix for me was:

--initialize-at-build-time=scala.runtime.Statics$VM

Which was weird because the error message didn't seem to indicate that but somehow I had another Scala app that led me to that.

I'm seeing the same problem, not with 19.3.1, but with 20.0.0.

I couldn't find the source of the problem in my case, but it could be something that is hidden in 19.3.1 with the use of --report-unsupported-elements-at-runtime

Actually, I found the source of the problem, it was this method: https://github.com/jOOQ/jOOQ/blob/version-3.13.0-branch/jOOQ/src/main/java/org/jooq/impl/DefaultRecordMapper.java#L597

By replacing it with an empty method using @Substitute, GraalVM 20.0.0 is happy and furthermore, it is without using --report-unsupported-elements-at-runtime. See https://github.com/jOOQ/jOOQ/issues/8779 for some details.

@christianwimmer Thanks for this fix, Christian—will it make it into the next release?

I have the more or less same question as @viktorklang @christianwimmer . This is unfortunately a blocking issue for me.

How will this be updated? Will it ship with GraalVM 20.1.0? Or will it come as an update via the gu tool to the native-image feature?

Another question. How would one go about debugging this issue? The stacktrace from the native image tool does not really point me in the direction regarding where this occurs in my code. If I knew where to look, I could create a workaround or something.

@sieveo I'm at the same stage as you: unable to make progress forward—I have no idea what caused the issue or what to work around.

The fix is now also merged into the 20.1 release branch (required a second merge because the release branches were created a few weeks ago). So it will be in the upcoming 20.1 release, i.e., one of the next 20.1 preview builds.

You can also grab a recent nightly build from master to check if the error is fixed for you.

And some ideas how to debug the underlying issue, i.e., to debug why java.lang.invoke.MethodHandleImpl$AsVarargsCollector.invokeWithArguments is reachable:
You can use the option -H:+PrintAnalysisCallTree to dump the entire call graph.
Or use the option -H:ReportAnalysisForbiddenType=java.lang.invoke.MethodHandleImpl$AsVarargsCollector to disallow that type completely and then see where the analysis fails.

@christianwimmer Where is the artifact for "org.graalvm.nativeimage:svm:20.1.0-dev" published, so I can depend on it?

I still get this error on 2.1.0-dev (but I had "org.graalvm.nativeimage:svm:20.0.0" on the classpath since I couldn't find the 2.1.0-dev artifact in any repo):

```[error] 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?
[error] object:java.lang.ref.SoftReference@59746bfa of class: java.lang.ref.SoftReference
[error] reachable through:
[error] object: [Ljava.lang.ref.SoftReference;@13f7a3bf of class: java.lang.ref.SoftReference[]
[error] object: Form(Object,Object,int,Object)void of class: java.lang.invoke.MethodTypeForm
[error] object: (MethodHandle,Object,int,Object)void of class: java.lang.invoke.MethodType
[error] object: MethodHandle(MethodHandle,Object,int,Object)void of class: java.lang.invoke.DirectMethodHandle
[error] object: [Ljava.lang.invoke.MethodHandle;@456b02b6 of class: java.lang.invoke.MethodHandle[]
[error] object: Invokers(Object,int,Object)void of class: java.lang.invoke.Invokers
[error] object: (Object,int,Object)void of class: java.lang.invoke.MethodType
[error] root: java.lang.invoke.MethodHandleImpl$AsVarargsCollector.invokeWithArguments(Object[])
[error] at com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:72)
[error] at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:648)
[error] at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:452)
[error] at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
[error] at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
[error] at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
[error] at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
[error] at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
[error] at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
[error] Caused by: com.oracle.svm.core.util.UserError$UserException: Static field or an object referenced from a static field changed during native image generation?
[error] object:java.lang.ref.SoftReference@59746bfa of class: java.lang.ref.SoftReference
[error] reachable through:
[error] object: [Ljava.lang.ref.SoftReference;@13f7a3bf of class: java.lang.ref.SoftReference[]
[error] object: Form(Object,Object,int,Object)void of class: java.lang.invoke.MethodTypeForm
[error] object: (MethodHandle,Object,int,Object)void of class: java.lang.invoke.MethodType
[error] object: MethodHandle(MethodHandle,Object,int,Object)void of class: java.lang.invoke.DirectMethodHandle
[error] object: [Ljava.lang.invoke.MethodHandle;@456b02b6 of class: java.lang.invoke.MethodHandle[]
[error] object: Invokers(Object,int,Object)void of class: java.lang.invoke.Invokers
[error] object: (Object,int,Object)void of class: java.lang.invoke.MethodType
[error] root: java.lang.invoke.MethodHandleImpl$AsVarargsCollector.invokeWithArguments(Object[])
[error] at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
[error] at com.oracle.svm.hosted.image.NativeImageHeapWriter.verifyTargetDidNotChange(NativeImageHeapWriter.java:130)
[error] at com.oracle.svm.hosted.image.NativeImageHeapWriter.writeReference(NativeImageHeapWriter.java:158)
[error] at com.oracle.svm.hosted.image.NativeImageHeapWriter.write(NativeImageHeapWriter.java:147)
[error] at com.oracle.svm.hosted.image.NativeImageHeapWriter.writeConstant(NativeImageHeapWriter.java:184)
[error] at com.oracle.svm.hosted.image.NativeImageHeapWriter.writeObject(NativeImageHeapWriter.java:377)
[error] at com.oracle.svm.hosted.image.NativeImageHeapWriter.writeHeap(NativeImageHeapWriter.java:89)
[error] at com.oracle.svm.hosted.image.NativeBootImage.build(NativeBootImage.java:483)
[error] at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:637)
[error] ... 7 more
[error] Error: Image build request failed with exit status 1
[error] com.oracle.svm.driver.NativeImage$NativeImageError: Image build request failed with exit status 1
[error] at com.oracle.svm.driver.NativeImage.showError(NativeImage.java:1541)
[error] at com.oracle.svm.driver.NativeImage.build(NativeImage.java:1299)
[error] at com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1260)
[error] at com.oracle.svm.driver.NativeImage.main(NativeImage.java:1219)
[error] at com.oracle.svm.driver.NativeImage$JDK9Plus.main(NativeImage.java:1722)
[error] stack trace is suppressed; run last proxy-core / Graalvm-native-image / packageBin for the full output


╭─[15:03:36] viktorklang@Tengil: ~/Documents/workspace/cloudstate
┆ wip-upgrade-to-2.6.x-√: ✘, 3 files changed, 9 insertions(+), 9 deletions(-)
╰─✘ echo $GRAALVM_HOME
/Users/viktorklang/Documents/workspace/tools/graalvm-ce-java11-20.1.0-dev/Contents/Home

╭─[15:03:41] viktorklang@Tengil: ~/Documents/workspace/cloudstate
┆ wip-upgrade-to-2.6.x-√: ✘, 3 files changed, 9 insertions(+), 9 deletions(-)
╰─○ which native-image
/Users/viktorklang/Documents/workspace/tools/graalvm-ce-java11-20.1.0-dev/Contents/Home/lib/svm/bin/native-image
```

@christianwimmer My issue seems to be caused by protobuf-java 3.10.0—you might be able to create a regression test from that code.

(this is from a shaded version of 3.10.0)
[error] Fatal error:com.oracle.graal.pointsto.util.AnalysisError$ParsingError: Error encountered while parsing java.lang.invoke.MethodHandleImpl.makeVarargsCollector(java.lang.invoke.MethodHandle, java.lang.Class) [error] Parsing context: [error] parsing java.lang.invoke.MethodHandle.asVarargsCollector(MethodHandle.java:1408) [error] parsing java.lang.invoke.MethodHandle.withVarargs(MethodHandle.java:1090) [error] parsing java.lang.invoke.MethodHandle.setVarargs(MethodHandle.java:1558) [error] parsing java.lang.invoke.MethodHandles$Lookup.getDirectMethodCommon(MethodHandles.java:2336) [error] parsing java.lang.invoke.MethodHandles$Lookup.getDirectMethod(MethodHandles.java:2271) [error] parsing java.lang.invoke.MethodHandles$Lookup.findStatic(MethodHandles.java:1103) [error] parsing java.lang.invoke.MethodHandleImpl.makeConstantHandle(MethodHandleImpl.java:2310) [error] parsing java.lang.invoke.MethodHandleImpl.getConstantHandle(MethodHandleImpl.java:2263) [error] parsing java.lang.invoke.MethodHandleImpl.makePairwiseConvertByEditor(MethodHandleImpl.java:302) [error] parsing java.lang.invoke.MethodHandleImpl.makePairwiseConvert(MethodHandleImpl.java:255) [error] parsing java.lang.invoke.MethodHandleImpl.throwException(MethodHandleImpl.java:1138) [error] parsing java.lang.invoke.MethodHandleImpl.fakeMethodHandleInvoke(MethodHandleImpl.java:1156) [error] parsing java.lang.invoke.MethodHandles$Lookup.unreflectForMH(MethodHandles.java:1752) [error] parsing java.lang.invoke.MethodHandles$Lookup.unreflect(MethodHandles.java:1733) [error] parsing akka.protobufv3.internal.GeneratedMessageV3$FieldAccessorTable$RepeatedFieldAccessor$MethodHandleInvoker.<init>(GeneratedMessageV3.java:2598) [error] parsing akka.protobufv3.internal.GeneratedMessageV3$FieldAccessorTable$RepeatedFieldAccessor.tryGetMethodHandleInvoke(GeneratedMessageV3.java:2710) [error] parsing akka.protobufv3.internal.GeneratedMessageV3$FieldAccessorTable$RepeatedFieldAccessor.<init>(GeneratedMessageV3.java:2702) [error] parsing akka.protobufv3.internal.GeneratedMessageV3$FieldAccessorTable$RepeatedMessageFieldAccessor.<init>(GeneratedMessageV3.java:3236) [error] parsing akka.protobufv3.internal.GeneratedMessageV3$FieldAccessorTable.ensureFieldAccessorsInitialized(GeneratedMessageV3.java:1984) [error] parsing akka.cluster.sharding.protobuf.msg.ClusterShardingMessages$StartEntityAck.internalGetFieldAccessorTable(ClusterShardingMessages.java:14157) [error] parsing akka.protobufv3.internal.GeneratedMessageV3.getDescriptorForType(GeneratedMessageV3.java:141) [error] parsing akka.protobufv3.internal.MessageReflection.findMissingFields(MessageReflection.java:173) [error] parsing akka.protobufv3.internal.MessageReflection.findMissingFields(MessageReflection.java:207) [error] parsing akka.protobufv3.internal.AbstractMessage$Builder.newUninitializedMessageException(AbstractMessage.java:477) [error] parsing akka.protobufv3.internal.AbstractMessage.newUninitializedMessageException(AbstractMessage.java:308) [error] parsing akka.protobufv3.internal.AbstractParser.newUninitializedMessageException(AbstractParser.java:53) [error] parsing akka.protobufv3.internal.AbstractParser.checkMessageInitialized(AbstractParser.java:67) [error] parsing akka.protobufv3.internal.AbstractParser.parseFrom(AbstractParser.java:191) [error] parsing akka.protobufv3.internal.AbstractParser.parseFrom(AbstractParser.java:203) [error] parsing akka.protobufv3.internal.AbstractParser.parseFrom(AbstractParser.java:208) [error] parsing akka.protobufv3.internal.AbstractParser.parseFrom(AbstractParser.java:48)

Was this page helpful?
0 / 5 - 0 ratings