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

GroovySubstitutions fails with groovy 4 #4492

Closed
JnRouvignac opened this issue Apr 14, 2022 · 6 comments
Closed

GroovySubstitutions fails with groovy 4 #4492

JnRouvignac opened this issue Apr 14, 2022 · 6 comments
Assignees
Labels

Comments

@JnRouvignac
Copy link

JnRouvignac commented Apr 14, 2022

Describe the issue
Upgrading groovy 3 to the newly released groovy 4 made native-image build fail with the following error: Error: Could not find target method: protected static void com.oracle.svm.polyglot.groovy.Target_org_codehaus_groovy_vmplugin_v7_IndyInterface_invalidateSwitchPoints.invalidateSwitchPoints()

Steps to reproduce the issue

Describe GraalVM and your environment:

  • GraalVM version: tested with
 $ java -version
openjdk version "11.0.9" 2020-10-20
OpenJDK Runtime Environment GraalVM CE 20.3.0 (build 11.0.9+10-jvmci-20.3-b06)
OpenJDK 64-Bit Server VM GraalVM CE 20.3.0 (build 11.0.9+10-jvmci-20.3-b06, mixed mode, sharing)

and:

$ java -version
openjdk version "11.0.14" 2022-01-18
OpenJDK Runtime Environment GraalVM CE 22.0.0.2 (build 11.0.14+9-jvmci-22.0-b05)
OpenJDK 64-Bit Server VM GraalVM CE 22.0.0.2 (build 11.0.14+9-jvmci-22.0-b05, mixed mode, sharing)
  • JDK major version: 11
  • OS: linux
  • Architecture: AMD64

More details
I saw that, while groovy 3 had IndyInterface.invalidateSwitchPoints(), groovy 4 does not have this method. These two commits removed it:

  • GROOVY-9380: VMPlugin refactor: Coalesce Java5 through Java7 into Java8
  • GROOVY-10465: Consolidation of VMPlugin didn't account for API calls in the Groovy runtime
    • apache/groovy@cc11133
    • adds back org.codehaus.groovy.vmplugin.v7.IndyInterface class, but without the invalidateSwitchPoints() method this time.

Here is the stack trace reported by the compiler:

15:41:32  Error: Could not find target method: protected static void com.oracle.svm.polyglot.groovy.Target_org_codehaus_groovy_vmplugin_v7_IndyInterface_invalidateSwitchPoints.invalidateSwitchPoints()
15:41:32  com.oracle.svm.core.util.UserError$UserException: Could not find target method: protected static void com.oracle.svm.polyglot.groovy.Target_org_codehaus_groovy_vmplugin_v7_IndyInterface_invalidateSwitchPoints.invalidateSwitchPoints()
15:41:32  	at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
15:41:32  	at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.findOriginalMethod(AnnotationSubstitutionProcessor.java:711)
15:41:32  	at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.handleMethodInAliasClass(AnnotationSubstitutionProcessor.java:365)
15:41:32  	at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.handleAliasClass(AnnotationSubstitutionProcessor.java:337)
15:41:32  	at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.handleClass(AnnotationSubstitutionProcessor.java:309)
15:41:32  	at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.init(AnnotationSubstitutionProcessor.java:265)
15:41:32  	at com.oracle.svm.hosted.NativeImageGenerator.createDeclarativeSubstitutionProcessor(NativeImageGenerator.java:921)
15:41:32  	at com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:855)
15:41:32  	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:556)
15:41:32  	at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:471)
15:41:32  	at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
15:41:32  	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
15:41:32  	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
15:41:32  	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
15:41:32  	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
15:41:32  	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
@oubidar-Abderrahim
Copy link
Member

Hi, Thank you for reporting this we will take a look into it and get back to you. In the meantime, could you please share the steps to reproduce this issue locally?

@oubidar-Abderrahim oubidar-Abderrahim self-assigned this Apr 18, 2022
@Torbuntu
Copy link

I ran into this as well.

Environment:

  • Linux, Fedora Silverblue x86_64
  • Groovy version: 4.0.2, JVM: 17.0.3 Vendor: GraalVM Community OS: Linux
]$ java --version
openjdk 17.0.3 2022-04-19
OpenJDK Runtime Environment GraalVM CE 22.1.0 (build 17.0.3+7-jvmci-22.1-b06)
OpenJDK 64-Bit Server VM GraalVM CE 22.1.0 (build 17.0.3+7-jvmci-22.1-b06, mixed mode, sharing)

Steps to reproduce:

  • Copy the gttp.groovy source from github/wololock/gttp
  • Compile with groovyc --compile-static gttp.groovy
  • Generate configuration with java -agentlib:native-image-agent=config-output-dir=conf/ -cp .:$GROOVY_HOME/lib/groovy-4.0.2.jar gttp
  • Attempt native-image: native-image --allow-incomplete-classpath --report-unsupported-elements-at-runtime --initialize-at-build-time --no-fallback --no-server -H:ConfigurationFileDirectories=conf -H:+ReportExceptionStackTraces -cp .:$GROOVY_HOME/lib/groovy-4.0.2.jar gttp

Results in the same stacktrace as original issue post.

If there is any other debugging I can try to provide more/better information please let me know.

@linghengqian
Copy link

linghengqian commented May 19, 2022

@paulk-asert
Copy link

With Groovy 4.0.3 (currently out for Apache release voting), the gttp app compiles successfully to a native image. We put a fix in place for the change which I believe caused the error. See https://issues.apache.org/jira/browse/GROOVY-10643.

Yet to be officially approved artifacts here:
https://dist.apache.org/repos/dist/dev/groovy/4.0.3/distribution

I did add org.codehaus.groovy.runtime.dgm$53 to the reflection config but otherwise followed the instructions as per above.

@Torbuntu
Copy link

Torbuntu commented Jun 8, 2022

Just confirming that upgrading to the new 4.0.3 version has resolved the issue and I was able to successfully generate a native image!

@JnRouvignac
Copy link
Author

Thanks for fixing this @paulk-asert, and thanks for confirming this is fixed @Torbuntu !

I am now closing this issue.
The problem existed from groovy 4.0.0 to 4.0.2 included.
Groovy 4.0.3 made a change to its code that fixes this problem.

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

No branches or pull requests

5 participants