You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Adrien Guichard <ad...@taack.org> on 2024/04/14 01:32:15 UTC
AST Transformation in Groovy 4.0.x VS 3.0.x
Is there any guideline to port AST Transformations for Groovy 4.0 ?
I am porting Taack-UI to Groovy 4.0, and I am stuck with errors like:
[. . . ]
General error during instruction selection: size==0
[. . .]
At the moment I just added casts at ReturnStatements. (See
https://github.com/Taack/infra/blob/main/taack-ui/src/main/groovy/taack/ast/model/TaackFieldEnumASTTransformation.groovy
)
Thanks !
--
Adrien Guichard
+ 33 6 10 78 75 88
https://taack.org
29 Boulevard Edgar Quinet
75014 Paris
France
Re: AST Transformation in Groovy 4.0.x VS 3.0.x
Posted by Adrien Guichard <ad...@taack.org>.
Le dim. 14 avr. 2024 à 03:32, Adrien Guichard
<ad...@taack.org> a écrit :
>
> Is there any guideline to port AST Transformations for Groovy 4.0 ?
>
> I am porting Taack-UI to Groovy 4.0, and I am stuck with errors like:
> [. . . ]
> General error during instruction selection: size==0
> [. . .]
>
>
> At the moment I just added casts at ReturnStatements. (See https://github.com/Taack/infra/blob/main/taack-ui/src/main/groovy/taack/ast/model/TaackFieldEnumASTTransformation.groovy)
More info:
Look around
- line 353 for getter method processing;
- line 321 for fields processing;
- line 170 for self;
Other parts of the code should depend on Grails only, so no impact.
The goal of those transformations is mainly to add getters with '_'
appended to add meta info to fields (like field name).
Regards
--
Adrien Guichard
+ 33 6 10 78 75 88
https://taack.org
29 Boulevard Edgar Quinet
75014 Paris
Re: AST Transformation in Groovy 4.0.x VS 3.0.x
Posted by Adrien Guichard <ad...@taack.org>.
Le dim. 14 avr. 2024 à 22:27, Adrien Guichard
<ad...@taack.org> a écrit :
>
> Le dim. 14 avr. 2024 à 17:44, MG <mg...@arscreat.com> a écrit :
> >
> > Just a long shot, but have you checked if this error might be due to a
> > broken build or similar, i.e. class files being modified in parallel or
> > source files having been modified while the build process was running ?
>
> I limit the number of spanning processes to 6 during gradle build, and
> the issue looks systematic.
>
> If this is the issue, I will open a bug report. I will restrict to 1
> concurrent process during build to test.
I reported the issue for Groovy 3.0.21:
https://issues.apache.org/jira/browse/GROOVY-11359
Regards
--
Adrien Guichard
+ 33 6 10 78 75 88
https://taack.org
29 Boulevard Edgar Quinet
75014 Paris
Re: AST Transformation in Groovy 4.0.x VS 3.0.x
Posted by Adrien Guichard <ad...@taack.org>.
Le dim. 14 avr. 2024 à 17:44, MG <mg...@arscreat.com> a écrit :
>
> Just a long shot, but have you checked if this error might be due to a
> broken build or similar, i.e. class files being modified in parallel or
> source files having been modified while the build process was running ?
I limit the number of spanning processes to 6 during gradle build, and
the issue looks systematic.
If this is the issue, I will open a bug report. I will restrict to 1
concurrent process during build to test.
> We see "ArrayIndexOutOfBoundsException: size==0" exceptions from time to
> time during IntelliJ Groovy builds, and the cause is typically as stated
> above. Building anew (sometimes rebuilding a module or the whole project
> is required) typically fixes these... (we had some which were actual
> bugs in the Groovy compiler, but these are very rare).
I removed '.gradle' from 'buildSrc' and from my home. No changes...
> On 14/04/2024 15:54, Adrien Guichard wrote:
> > Le dim. 14 avr. 2024 à 12:18, Paul King <pa...@asert.com.au> a écrit :
> >> Can you give us more of the stack trace where Groovy is failing for
> >> the "size==0" error?
> > java.lang.ArrayIndexOutOfBoundsException: size==0
> > at org.codehaus.groovy.classgen.asm.OperandStack.ensureStackNotEmpty(OperandStack.java:279)
> > at org.codehaus.groovy.classgen.asm.OperandStack.replace(OperandStack.java:271)
[. . .]
> >
> >> I would in general expect very few changes needed between 3 and 4.
> > I was wrong, Grails 6.2.0 is Groovy 3.0.21 (from 3.0.11)
--
Adrien Guichard
+ 33 6 10 78 75 88
https://taack.org
29 Boulevard Edgar Quinet
75014 Paris
Re: AST Transformation in Groovy 4.0.x VS 3.0.x
Posted by MG <mg...@arscreat.com>.
Just a long shot, but have you checked if this error might be due to a
broken build or similar, i.e. class files being modified in parallel or
source files having been modified while the build process was running ?
We see "ArrayIndexOutOfBoundsException: size==0" exceptions from time to
time during IntelliJ Groovy builds, and the cause is typically as stated
above. Building anew (sometimes rebuilding a module or the whole project
is required) typically fixes these... (we had some which were actual
bugs in the Groovy compiler, but these are very rare).
Cheers,
mg
On 14/04/2024 15:54, Adrien Guichard wrote:
> Le dim. 14 avr. 2024 à 12:18, Paul King <pa...@asert.com.au> a écrit :
>> Can you give us more of the stack trace where Groovy is failing for
>> the "size==0" error?
> java.lang.ArrayIndexOutOfBoundsException: size==0
> at org.codehaus.groovy.classgen.asm.OperandStack.ensureStackNotEmpty(OperandStack.java:279)
> at org.codehaus.groovy.classgen.asm.OperandStack.replace(OperandStack.java:271)
> at org.codehaus.groovy.classgen.AsmClassGenerator.visitCastExpression(AsmClassGenerator.java:815)
> at org.codehaus.groovy.ast.expr.CastExpression.visit(CastExpression.java:90)
> at org.codehaus.groovy.classgen.asm.StatementWriter.writeReturn(StatementWriter.java:615)
> at org.codehaus.groovy.classgen.AsmClassGenerator.visitReturnStatement(AsmClassGenerator.java:682)
> at org.codehaus.groovy.ast.stmt.ReturnStatement.visit(ReturnStatement.java:73)
> at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:138)
> at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:111)
> at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:462)
> at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:409)
> at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:106)
> at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:557)
> at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1100)
> at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1093)
> at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52)
> at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:273)
> at org.codehaus.groovy.control.CompilationUnit$3.call(CompilationUnit.java:798)
> at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:943)
> at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:672)
> at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:636)
> at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:611)
> at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:285)
> at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:67)
> at org.gradle.api.internal.tasks.compile.GroovyCompilerFactory$DaemonSideCompiler.execute(GroovyCompilerFactory.java:97)
> at org.gradle.api.internal.tasks.compile.GroovyCompilerFactory$DaemonSideCompiler.execute(GroovyCompilerFactory.java:76)
> at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerWorkAction.execute(AbstractDaemonCompiler.java:135)
> at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
> at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:49)
> at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:43)
> at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100)
> at org.gradle.workers.internal.AbstractClassLoaderWorker.executeInClassLoader(AbstractClassLoaderWorker.java:43)
> at org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:49)
> at org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:30)
> at org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:87)
> at org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:56)
> at org.gradle.process.internal.worker.request.WorkerAction$1.call(WorkerAction.java:138)
> at org.gradle.process.internal.worker.child.WorkerLogEventListener.withWorkerLoggingProtocol(WorkerLogEventListener.java:41)
> at org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:135)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
> at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.base/java.lang.reflect.Method.invoke(Method.java:568)
> at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
> at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
> at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
> at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
> at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414)
> at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
> at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:49)
> at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
> at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
> at java.base/java.lang.Thread.run(Thread.java:840)
>
>
>> I would in general expect very few changes needed between 3 and 4.
> I was wrong, Grails 6.2.0 is Groovy 3.0.21 (from 3.0.11)
>
>> Groovy's built-in AST transforms had almost no changes.
>>
>> Cheers, Paul.
> Thanks !
>
Re: AST Transformation in Groovy 4.0.x VS 3.0.x
Posted by Adrien Guichard <ad...@taack.org>.
Le dim. 14 avr. 2024 à 12:18, Paul King <pa...@asert.com.au> a écrit :
>
> Can you give us more of the stack trace where Groovy is failing for
> the "size==0" error?
java.lang.ArrayIndexOutOfBoundsException: size==0
at org.codehaus.groovy.classgen.asm.OperandStack.ensureStackNotEmpty(OperandStack.java:279)
at org.codehaus.groovy.classgen.asm.OperandStack.replace(OperandStack.java:271)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitCastExpression(AsmClassGenerator.java:815)
at org.codehaus.groovy.ast.expr.CastExpression.visit(CastExpression.java:90)
at org.codehaus.groovy.classgen.asm.StatementWriter.writeReturn(StatementWriter.java:615)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitReturnStatement(AsmClassGenerator.java:682)
at org.codehaus.groovy.ast.stmt.ReturnStatement.visit(ReturnStatement.java:73)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:138)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:111)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:462)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:409)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:106)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:557)
at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1100)
at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1093)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:273)
at org.codehaus.groovy.control.CompilationUnit$3.call(CompilationUnit.java:798)
at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:943)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:672)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:636)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:611)
at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:285)
at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:67)
at org.gradle.api.internal.tasks.compile.GroovyCompilerFactory$DaemonSideCompiler.execute(GroovyCompilerFactory.java:97)
at org.gradle.api.internal.tasks.compile.GroovyCompilerFactory$DaemonSideCompiler.execute(GroovyCompilerFactory.java:76)
at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerWorkAction.execute(AbstractDaemonCompiler.java:135)
at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:49)
at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:43)
at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100)
at org.gradle.workers.internal.AbstractClassLoaderWorker.executeInClassLoader(AbstractClassLoaderWorker.java:43)
at org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:49)
at org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:30)
at org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:87)
at org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:56)
at org.gradle.process.internal.worker.request.WorkerAction$1.call(WorkerAction.java:138)
at org.gradle.process.internal.worker.child.WorkerLogEventListener.withWorkerLoggingProtocol(WorkerLogEventListener.java:41)
at org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:135)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:840)
>
> I would in general expect very few changes needed between 3 and 4.
I was wrong, Grails 6.2.0 is Groovy 3.0.21 (from 3.0.11)
> Groovy's built-in AST transforms had almost no changes.
>
> Cheers, Paul.
Thanks !
--
Adrien Guichard
+ 33 6 10 78 75 88
https://taack.org
29 Boulevard Edgar Quinet
75014 Paris
Re: AST Transformation in Groovy 4.0.x VS 3.0.x
Posted by Paul King <pa...@asert.com.au>.
Can you give us more of the stack trace where Groovy is failing for
the "size==0" error?
I would in general expect very few changes needed between 3 and 4.
Groovy's built-in AST transforms had almost no changes.
Cheers, Paul.
On Sun, Apr 14, 2024 at 11:31 AM Adrien Guichard
<ad...@taack.org> wrote:
>
> Is there any guideline to port AST Transformations for Groovy 4.0 ?
>
> I am porting Taack-UI to Groovy 4.0, and I am stuck with errors like:
> [. . . ]
> General error during instruction selection: size==0
> [. . .]
>
> At the moment I just added casts at ReturnStatements. (See https://github.com/Taack/infra/blob/main/taack-ui/src/main/groovy/taack/ast/model/TaackFieldEnumASTTransformation.groovy)
>
> Thanks !
>
> --
> Adrien Guichard
> + 33 6 10 78 75 88
> https://taack.org
> 29 Boulevard Edgar Quinet
> 75014 Paris
> France