[ 
https://issues.apache.org/jira/browse/GROOVY-11359?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17837497#comment-17837497
 ] 

Adrien Guichard edited comment on GROOVY-11359 at 4/16/24 3:36 AM:
-------------------------------------------------------------------

{quote}Classgen is processing the CastExpression when it finds that the operand 
stack is empty. The cast is the expression of the method's ReturnStatement. The 
operand stack underflow occurrs somewhere in you ConstructorCallExpression. One 
thing to try that is a common source of problems is capturing your 
MethodCallExpression and calling setImplicitThis(false) on it.
{quote}
Thanks for those advises, I can even get ride of the cast... I will give it a 
try.
{quote}You can also set the return type of your method node to retClassNode 
instead of makeClassSafeWithGenerics(GetMethodReturn...
{quote}
I already do this, I might have done something wrong, but I get the same error.
{quote}And I don't know if it helps to set the type of the 
StaticMethodCallExpression to String. You could step through the class 
generator and see what is on the operand stack as it works its way through the 
CCE.
{quote}
Sure it helps ! In fact it is the return type of the {{String getTtuc();}} 
method, but I am thinking now : "Why a Static call on a non-static class 
member...".

I will try to step through the class generator, even if I am not sure how to do 
that ATM. Do I need to debug build ? or I am misunderstanding ?

Many thanks !


was (Author: adrienguichard):
{quote}Classgen is processing the CastExpression when it finds that the operand 
stack is empty. The cast is the expression of the method's ReturnStatement. The 
operand stack underflow occurrs somewhere in you ConstructorCallExpression. One 
thing to try that is a common source of problems is capturing your 
MethodCallExpression and calling setImplicitThis(false) on it.
{quote}
Thanks for those advises, I can even get ride of the cast... I will give it a 
try.
{quote}You can also set the return type of your method node to retClassNode 
instead of makeClassSafeWithGenerics(GetMethodReturn...
{quote}
I already do this, I might have done something wrong, but I get the same error.
{quote}And I don't know if it helps to set the type of the 
StaticMethodCallExpression to String. You could step through the class 
generator and see what is on the operand stack as it works its way through the 
CCE.
{quote}
Sure it helps ! In fact it is the return type of the {{String getTtuc();}} 
method, but I am thinking now : "Why a Static call on a non-static class 
member...". I will try to step through the class generator, even if I am not 
sure how to do that ATM. Do I need to debug build ? or I am misunderstanding ?

Many thanks

> ASTTransformation cause "General error during instruction selection"
> --------------------------------------------------------------------
>
>                 Key: GROOVY-11359
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11359
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 3.0.21
>         Environment: $ java -fullversion
> openjdk full version "17.0.10+7"
> $ uname -a
> Linux auoHome 6.6.26-1-MANJARO #1 SMP PREEMPT_DYNAMIC Wed Apr 10 20:11:08 UTC 
> 2024 x86_64 GNU/Linux
>            Reporter: Adrien Guichard
>            Priority: Major
>             Fix For: 3.0.11
>
>         Attachments: testcase-asttransform-ko.tar.gz
>
>
> When assembling the *Grails* project, I do obtain the following stacktrace:
>  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)
> [. . .]
> Tell me if you need a more complete stacktrace. I try to work around this 
> bug, changing the AST, without success. The error looks the same {*}each 
> time{*}.
> To reproduce:
> $ tar xvfz testcase-asttransform-ko.tar.gz
> $ cd groovyInfra
> $ ./gradlew publishMavenPublicationToMavenLocal
> $ cd ..
> $ cd t620g
> $ ./gradlew assemble
> => BROKEN HERE
> Thanks for your help !



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to