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

Daniel Spilker commented on GROOVY-7826:
----------------------------------------

DecompiledClassNode should be fixed if that behavior is not expected. But 
ClassNode#toString needs to fixed in any case.

What is bad about the fix in PR #333? Are the redirects for type arguments 
really important for #toString? What is the expected behavior for #toString?

This is the computed value with the fix:
{code}
C1 -> C1 <T2 extends C2 <T2, T1>, T1 extends C1>
{code}

This is the computed value without the fix and with ASM resolving enabled:
{code}
C1 -> C1 <T2 extends C2 <T2, T1> -> C2, T1 extends C1>
{code}

Without the fix and without ASM resolving, the computation never stops:
{code}
C1 -> C1 <T2 extends C2 <T2, T1> -> C2 <T2 extends C2, T1 extends C1 <T2, T1> 
-> C1 <T2 extends C2 <T2, T1> -> C2 <T2 extends C2, T1 extends C1 <T2, T1> -> 
...
{code}

This is the same ouput as above without the fix and with ASM resolving enabled, 
but I added (class.name@identityHashCode) to the type name to show the 
instances:
{code}
C1(org.codehaus.groovy.ast.ClassNode@12e335ef) -> 
C1(org.codehaus.groovy.ast.decompiled.DecompiledClassNode@2e9e799) <T2 extends 
C2(org.codehaus.groovy.ast.ClassNode@4a63ef4d) <T2, T1> -> 
C2(org.codehaus.groovy.ast.decompiled.DecompiledClassNode@66f3ce62), T1 extends 
C1>
{code}

... and with ASM resolving disabled:
{code}
C1(org.codehaus.groovy.ast.ClassNode@7c91f442) -> 
C1(org.codehaus.groovy.ast.ClassNode@523b58f2) <T2 extends 
C2(org.codehaus.groovy.ast.ClassNode@364ca20b) <T2, T1> -> 
C2(org.codehaus.groovy.ast.ClassNode@61229c06) <T2 extends C2, T1 extends 
C1(org.codehaus.groovy.ast.ClassNode@27317fbc) <T2, T1> -> 
C1(org.codehaus.groovy.ast.ClassNode@523b58f2) <T2 ...
{code}

PS: I removed the {{org.codehaus.groovy.ast.Groovy7862Bug$}} prefix for the 
names of C1 and C2 for brevity.

PPS: Shouldn't the expected value should be this?
{code}
C1 -> C1<T2 extends C2<T2, T1>, T1 extends C1<T2, T1>>
{code}


> Infinite recursion in genericTypeAsString
> -----------------------------------------
>
>                 Key: GROOVY-7826
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7826
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.6
>         Environment: Groovy Version: 2.4.6 JVM: 1.8.0_91 Vendor: Oracle 
> Corporation OS: Linux
>            Reporter: Magnus Reftel
>              Labels: regresion
>         Attachments: groovy-7826.zip
>
>
> The following two Java classes C1 and C2 cause Groovy to enter infinite 
> recursion in genericTypeAsString when a method that takes a C1 is declared:
> C1.java:
> public class C1 <T2 extends C2<T2,T1>,T1 extends C1<T2,T1>> { }
> class C2<T2 extends C2<T2, T1>, T1 extends C1<T2, T1>> { }
> repro.groovy
> def f(C1 c1) { }
> This is reduced from actual code in Jenkins, where Run and Job have type 
> parameters like this.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to