How to add flag '--enable-preview' to groovy compiler

Answered

Hi

I have a mixed java/gorrvy project., IntelliJ IntelliJ IDEA 2019.3.2 (Community Edition) Build #IC-193.6015.39, built on January 21, 2020

I want to use JDK 13 preview features, so I turned it on in java language.

But now groovyc fails

    Preview features are not enabled for utils/annotation/Nullable (class file version 57.65535). Try running with '--enable-preview'

I want to add  '--enable-preview' to groovy compiler, see https://issues.apache.org/jira/browse/GROOVY-9073

but can't find how to do it 

Thanks

Boaz

4 comments
Comment actions Permalink

Did you find any solution? We have exactly the same problem.

0
Comment actions Permalink

Please try to add -Dgroovy.preview.features=true to build process VM options (shared or user) in Preferences | Build, Execution, Deployment | Compiler

0
Comment actions Permalink

Thanks fro the feedback, tried it, exactly same results.

 

Error:Groovyc: While compiling Infra: BUG! exception in phase 'semantic analysis' in source unit 'F:\views\g\QsystemTools\Qsystem\Qsys_tools\tools\Infra\src\amat\deploy\ToolDeployment.groovy' Problem loading class utils.annotation.Nullable
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:960)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:635)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:585)
at org.jetbrains.groovy.compiler.rt.GroovyCompilerWrapper.compile(GroovyCompilerWrapper.java:62)
at org.jetbrains.groovy.compiler.rt.DependentGroovycRunner.runGroovyc(DependentGroovycRunner.java:108)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.jetbrains.groovy.compiler.rt.GroovycRunner.intMain2(GroovycRunner.java:90)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.jetbrains.jps.incremental.groovy.InProcessGroovyc.runGroovycInThisProcess(InProcessGroovyc.java:157)
at org.jetbrains.jps.incremental.groovy.InProcessGroovyc.lambda$runGroovyc$0(InProcessGroovyc.java:76)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:830)
Caused by: java.lang.RuntimeException: Problem loading class utils.annotation.Nullable
at org.jetbrains.groovy.compiler.rt.DependentGroovycRunner$7$1.loadClass(DependentGroovycRunner.java:515)
at org.codehaus.groovy.ast.decompiled.AsmReferenceResolver.resolveJvmClass(AsmReferenceResolver.java:84)
at org.codehaus.groovy.ast.decompiled.DecompiledClassNode.getTypeClass(DecompiledClassNode.java:175)
at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1399)
at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1399)
at org.codehaus.groovy.control.ResolveVisitor.visitAnnotations(ResolveVisitor.java:1337)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:110)
at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitConstructorOrMethod(ClassCodeExpressionTransformer.java:66)
at org.codehaus.groovy.control.ResolveVisitor.visitConstructorOrMethod(ResolveVisitor.java:283)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:106)
at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1108)
at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1101)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52)
at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1463)
at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:256)
at org.codehaus.groovy.control.CompilationUnit$13.call(CompilationUnit.java:691)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:956)
... 19 more
Caused by: java.lang.UnsupportedClassVersionError: Preview features are not enabled for utils/annotation/Nullable (class file version 57.65535). Try running with '--enable-preview'
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:877)
at com.intellij.util.lang.UrlClassLoader._defineClass(UrlClassLoader.java:380)
at org.jetbrains.jps.incremental.groovy.JointCompilationClassLoader._defineClass(JointCompilationClassLoader.java:38)
at com.intellij.util.lang.UrlClassLoader.defineClass(UrlClassLoader.java:376)
at com.intellij.util.lang.UrlClassLoader._findClass(UrlClassLoader.java:340)
at com.intellij.util.lang.UrlClassLoader.findClass(UrlClassLoader.java:326)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:575)
at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:866)
at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:741)
at org.jetbrains.groovy.compiler.rt.DependentGroovycRunner$7$1.loadClass(DependentGroovycRunner.java:509)
... 35 more

0
Comment actions Permalink

Jan Krakora not yet.Very frustrating

0

Please sign in to leave a comment.