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

Compilation fails without --report-unsupported-elements-at-runtime #2829

Closed
agilob opened this issue Sep 3, 2020 · 6 comments
Closed

Compilation fails without --report-unsupported-elements-at-runtime #2829

agilob opened this issue Sep 3, 2020 · 6 comments

Comments

@agilob
Copy link

agilob commented Sep 3, 2020

Describe the issue

I'm getting the error below when native-image.properties doesn't contain --report-unsupported-elements-at-runtime

Uncommenting the parameter produces working native-image.

Steps to reproduce the issue
Please include both build steps as well as run steps

  1. git clone [email protected]:agilob/mhipster-graal.git
  2. MICRONAUT_ENVIRONMENTS=prod ./gradlew assemble && bash ./docker-build.sh

Describe GraalVM and your environment:
Graal docker image: 20.2.0
SubstrateVM (dependency in build.gradle) 20.2.0

More details

Meta-inf

Dockerfile

Add any other information about the problem here. Especially important are stack traces or log output. Feel free to link to gists or to screenshots if necessary.

Step 5/10 : RUN native-image -cp build/libs/*-all.jar
 ---> Running in 9ea3687739f3
[mhip-2:24]    classlist:  11,375.88 ms,  1.69 GB
[mhip-2:24]        (cap):     651.01 ms,  1.69 GB
[mhip-2:24]        setup:   1,942.78 ms,  1.69 GB
[mhip-2:24]     (clinit):   1,303.98 ms,  6.37 GB
[mhip-2:24]   (typeflow):  21,122.14 ms,  6.37 GB
[mhip-2:24]    (objects):  31,288.27 ms,  6.37 GB
[mhip-2:24]   (features):  13,263.10 ms,  6.37 GB
[mhip-2:24]     analysis:  70,865.06 ms,  6.37 GB
Error: Unsupported features in 2 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:                                                                                                                                                                                                                                            

Call path from entry point to java.lang.invoke.LambdaForm$MH/755782116.invokeExact_MT(Object, Object):                                                                                                                                            


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:                                                                                                                                                                                                                                            

Call path from entry point to java.lang.invoke.MethodHandles$Lookup.findStatic(Class, String, MethodType):                                                                                                                                        


com.oracle.svm.core.util.UserError$UserException: Unsupported features in 2 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:                                                                                                                                                                                                                                            

Call path from entry point to java.lang.invoke.LambdaForm$MH/755782116.invokeExact_MT(Object, Object):                                                                                                                                            


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:                                                                                                                                                                                                                                            

Call path from entry point to java.lang.invoke.MethodHandles$Lookup.findStatic(Class, String, MethodType):                                                                                                                                        


Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Unsupported features in 2 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:                                                                                                                                                                                                                                            

Call path from entry point to java.lang.invoke.LambdaForm$MH/755782116.invokeExact_MT(Object, Object):                                                                                                                                            


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:                                                                                                                                                                                                                                            

Call path from entry point to java.lang.invoke.MethodHandles$Lookup.findStatic(Class, String, MethodType):                                                                                                                                        


Error: Image build request failed with exit status 1                                                                                                                                                                                              
The command '/bin/sh -c native-image -cp build/libs/*-all.jar' returned a non-zero code: 1
@oubidar-Abderrahim
Copy link
Member

@agilob did you try to run the native-image-agent to generate config files?

@agilob
Copy link
Author

agilob commented Sep 4, 2020

I have run java -jar -agentlib:native-image-agent=config-output-dir=config-files build/libs/mhip-2-0.0.1-SNAPSHOT-all.jar before and put simplified generated config files to meta-inf.

By simplified I mean I removed some classes that micronaut handles during compilation, so it would be duplicated.

@agilob
Copy link
Author

agilob commented Sep 4, 2020

@graemerocher commented on gitter that method handles aren't supported yet by graal. Is this a duplicate then?

@oubidar-Abderrahim
Copy link
Member

oubidar-Abderrahim commented Sep 4, 2020

Yes indeed, method handlers are not supported by GraalVM currently. This is a duplicate

@agilob
Copy link
Author

agilob commented Sep 4, 2020

Can you please link duplicates together and where is this being worked on?

@oubidar-Abderrahim
Copy link
Member

Duplicate of #955
As mentioned in #955, MethodHandle allows nested composition, i.e., complex arbitrary expressions that can be changed at run time and therefore not compiled ahead of time.

Maybe @christianwimmer can shed more light on this.

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

No branches or pull requests

2 participants