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

[native-image] "Static field or an object referenced from a static field changed during native image generation" (involving java.lang.ref.SoftReference@) #2399

Closed
xhiroga opened this issue Apr 26, 2020 · 1 comment · Fixed by #2407
Assignees
Milestone

Comments

@xhiroga
Copy link

xhiroga commented Apr 26, 2020

Describe the issue
Trying to generate a native image from a jar file. An external library I use may cause the problem but I cannot figure out what is wrong.

The error may be related to this line.
https://github.com/hiroga-cc/excel/blob/e797739c0ebb9d61ba0327c0735ea78cba3c7fb5/src/main/kotlin/cc/hiroga/excel/Commands.kt#L21

This is the stacktrace

native-image --report-unsupported-elements-at-runtime -jar build/libs/excel-1.0-SNAPSHOT-all.jar excel --no-server
[excel:60258]    classlist:  21,088.55 ms,  2.31 GB
[excel:60258]        (cap):   3,838.12 ms,  2.31 GB
[excel:60258]        setup:   9,984.70 ms,  2.31 GB
[excel:60258]   (typeflow): 122,211.32 ms,  2.80 GB
[excel:60258]    (objects):  17,201.16 ms,  2.80 GB
[excel:60258]   (features):     952.64 ms,  2.80 GB
[excel:60258]     analysis: 141,092.80 ms,  2.80 GB
[excel:60258]     (clinit):   1,013.39 ms,  2.80 GB
[excel:60258]     universe:   2,396.48 ms,  2.80 GB
[excel:60258]      (parse):  91,949.93 ms,  3.14 GB
[excel:60258]     (inline):   4,115.45 ms,  3.20 GB
[excel:60258]    (compile):  40,709.89 ms,  3.61 GB
[excel:60258]      compile: 138,845.04 ms,  3.61 GB
[excel:60258]        image:   2,638.55 ms,  3.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@7fe86eab  of class: java.lang.ref.SoftReference
  reachable through:
    object: [Ljava.lang.ref.SoftReference;@78f96a49  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: MethodHandle.invokeBasic  of class: java.lang.invoke.LambdaForm$NamedFunction
    object: t5:V  of class: java.lang.invoke.LambdaForm$Name
    object: [Ljava.lang.invoke.LambdaForm$Name;@1a88b58c  of class: java.lang.invoke.LambdaForm$Name[]
    object: MH.delegate=Lambda(a0:L/DelegatingMethodHandle,a1:L,a2:I,a3:L)=>{
    t4:L=DelegatingMethodHandle.getTarget(a0:L);
    t5:V=MethodHandle.invokeBasic(t4:L,a1:L,a2:I,a3:L);void}  of class: java.lang.invoke.LambdaForm
    object: java.lang.ref.SoftReference@280df4a6  of class: java.lang.ref.SoftReference
    object: [Ljava.lang.ref.SoftReference;@3ee645b9  of class: java.lang.ref.SoftReference[]
    object: Form(Object,int,Object)void  of class: java.lang.invoke.MethodTypeForm
    object: (Object[],int,Object)void  of class: java.lang.invoke.MethodType
    object: MethodHandle(Object[],int,Object)void  of class: java.lang.invoke.DirectMethodHandle
    object: MethodHandle(Object[],int,Object)void  of class: java.lang.invoke.MethodHandleImpl$IntrinsicMethodHandle
    root: java.lang.invoke.MethodHandleImpl.makeArrayElementAccessor(Class, boolean)

        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.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)
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@7fe86eab  of class: java.lang.ref.SoftReference
  reachable through:
    object: [Ljava.lang.ref.SoftReference;@78f96a49  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: MethodHandle.invokeBasic  of class: java.lang.invoke.LambdaForm$NamedFunction
    object: t5:V  of class: java.lang.invoke.LambdaForm$Name
    object: [Ljava.lang.invoke.LambdaForm$Name;@1a88b58c  of class: java.lang.invoke.LambdaForm$Name[]
    object: MH.delegate=Lambda(a0:L/DelegatingMethodHandle,a1:L,a2:I,a3:L)=>{
    t4:L=DelegatingMethodHandle.getTarget(a0:L);
    t5:V=MethodHandle.invokeBasic(t4:L,a1:L,a2:I,a3:L);void}  of class: java.lang.invoke.LambdaForm
    object: java.lang.ref.SoftReference@280df4a6  of class: java.lang.ref.SoftReference
    object: [Ljava.lang.ref.SoftReference;@3ee645b9  of class: java.lang.ref.SoftReference[]
    object: Form(Object,int,Object)void  of class: java.lang.invoke.MethodTypeForm
    object: (Object[],int,Object)void  of class: java.lang.invoke.MethodType
    object: MethodHandle(Object[],int,Object)void  of class: java.lang.invoke.DirectMethodHandle
    object: MethodHandle(Object[],int,Object)void  of class: java.lang.invoke.MethodHandleImpl$IntrinsicMethodHandle
    root: java.lang.invoke.MethodHandleImpl.makeArrayElementAccessor(Class, boolean)

        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)
        ... 6 more
Error: Image build request failed with exit status 1
make: *** [excel] Error 1

Steps to reproduce the issue
Please run below steps.

  1. git clone https://github.com/hiroga-cc/excel
  2. make

Describe GraalVM and your environment:

  • GraalVM version: graalvm-ce-java8
  • JDK major version: openjdk version "1.8.0_222"
  • OS: macOS 10.15.3
@christianwimmer
Copy link

#2407 fixes the problem during image heap writing. That still does not mean that the MethodHandle usage in that application is going to work.

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

Successfully merging a pull request may close this issue.

3 participants