[ 
https://issues.apache.org/jira/browse/GROOVY-8111?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Eric Milles updated GROOVY-8111:
--------------------------------
    Description: 
I have run into this stack overflow error a few times when editing a Groovy 
file.  Consider the following:
{code:groovy}
// excerpt of org.apache.commons.lang3.tuple.Pair
class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L, R>>, 
Serializable {
  public final L left
  public final R right

  private Pair(final L left, final R right) {
    this.left = left
    this.right = right
  }

  static <L, R> Pair<L, R> of(final L left, final R right) {
    return new Pair<>(left, right)
  }

  L getKey() { left }
  R getValue() { right }
  R setValue(R value) { right }
  int compareTo(Pair<L,R> that) { 0 }
}

@groovy.transform.TypeChecked
def test(thing) {
  thing != null ?: Pair.of('', ['']) // STCV is trying to get LUB of boolean 
and Pair<String,List<String>>
}

test(null)
{code}

The problem appears in {{WideningCategories}}' {{lowestUpperBound}} and 
{{parameterizeLowestUpperBound}}.

Captured on Groovy 2.4.9:
{code:java}
java.lang.StackOverflowError
        at org.codehaus.groovy.ast.ClassNode.getText(ClassNode.java:1686)
        at org.codehaus.groovy.ast.ClassNode.equals(ClassNode.java:813)
        at org.codehaus.groovy.ast.ClassNode.equals(ClassNode.java:810)
        at 
org.codehaus.groovy.ast.ClassNode.declaresInterface(ClassNode.java:1082)
        at 
org.codehaus.groovy.ast.ClassNode.implementsInterface(ClassNode.java:1060)
        at 
org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf(StaticTypeCheckingSupport.java:798)
        at 
org.codehaus.groovy.ast.tools.GenericsUtils.extractSuperClassGenerics(GenericsUtils.java:434)
        at 
org.codehaus.groovy.ast.tools.GenericsUtils.parameterizeType(GenericsUtils.java:228)
        at 
org.codehaus.groovy.ast.tools.WideningCategories.findGenericsTypeHolderForClass(WideningCategories.java:269)
        at 
org.codehaus.groovy.ast.tools.WideningCategories.parameterizeLowestUpperBound(WideningCategories.java:233)
        at 
org.codehaus.groovy.ast.tools.WideningCategories.lowestUpperBound(WideningCategories.java:203)
        at 
org.codehaus.groovy.ast.tools.WideningCategories.parameterizeLowestUpperBound(WideningCategories.java:250)
        at 
org.codehaus.groovy.ast.tools.WideningCategories.lowestUpperBound(WideningCategories.java:203)
        at 
org.codehaus.groovy.ast.tools.WideningCategories.parameterizeLowestUpperBound(WideningCategories.java:250)
        at 
org.codehaus.groovy.ast.tools.WideningCategories.lowestUpperBound(WideningCategories.java:203)
        at 
org.codehaus.groovy.ast.tools.WideningCategories.parameterizeLowestUpperBound(WideningCategories.java:250)
        at 
org.codehaus.groovy.ast.tools.WideningCategories.lowestUpperBound(WideningCategories.java:203)
{code}

  was:
I have run into this stack overflow error a few times when editing a Groovy 
file.  Consider the following:
{code:groovy}
// excerpt of org.apache.commons.lang3.tuple.Pair
class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L, R>>, 
Serializable {
  public final L left
  public final R right

  private Pair(final L left, final R right) {
    this.left = left
    this.right = right
  }

  static <L, R> Pair<L, R> of(final L left, final R right) {
    return new Pair<>(left, right)
  }

  L getKey() { left }
  R getValue() { right }
  R setValue(R value) { right }
  int compareTo(Pair<L,R> that) { 0 }
}

@groovy.transform.TypeChecked
def test(thing) {
  thing != null ?: Pair.of('', [''])
}

test(null)
{code}

The problem appears in WideningCategories.lowestUpperBound and its callees.

Captured on Groovy 2.4.9:
{code:java}
java.lang.StackOverflowError
        at org.codehaus.groovy.ast.ClassNode.getText(ClassNode.java:1686)
        at org.codehaus.groovy.ast.ClassNode.equals(ClassNode.java:813)
        at org.codehaus.groovy.ast.ClassNode.equals(ClassNode.java:810)
        at 
org.codehaus.groovy.ast.ClassNode.declaresInterface(ClassNode.java:1082)
        at 
org.codehaus.groovy.ast.ClassNode.implementsInterface(ClassNode.java:1060)
        at 
org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf(StaticTypeCheckingSupport.java:798)
        at 
org.codehaus.groovy.ast.tools.GenericsUtils.extractSuperClassGenerics(GenericsUtils.java:434)
        at 
org.codehaus.groovy.ast.tools.GenericsUtils.parameterizeType(GenericsUtils.java:228)
        at 
org.codehaus.groovy.ast.tools.WideningCategories.findGenericsTypeHolderForClass(WideningCategories.java:269)
        at 
org.codehaus.groovy.ast.tools.WideningCategories.parameterizeLowestUpperBound(WideningCategories.java:233)
        at 
org.codehaus.groovy.ast.tools.WideningCategories.lowestUpperBound(WideningCategories.java:203)
        at 
org.codehaus.groovy.ast.tools.WideningCategories.parameterizeLowestUpperBound(WideningCategories.java:250)
        at 
org.codehaus.groovy.ast.tools.WideningCategories.lowestUpperBound(WideningCategories.java:203)
        at 
org.codehaus.groovy.ast.tools.WideningCategories.parameterizeLowestUpperBound(WideningCategories.java:250)
        at 
org.codehaus.groovy.ast.tools.WideningCategories.lowestUpperBound(WideningCategories.java:203)
        at 
org.codehaus.groovy.ast.tools.WideningCategories.parameterizeLowestUpperBound(WideningCategories.java:250)
        at 
org.codehaus.groovy.ast.tools.WideningCategories.lowestUpperBound(WideningCategories.java:203)
{code}


> Stack overflow between WideningCategories lowestUpperBound and 
> parameterizeLowestUpperBound
> -------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-8111
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8111
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.5.14
>            Reporter: Eric Milles
>            Priority: Major
>
> I have run into this stack overflow error a few times when editing a Groovy 
> file.  Consider the following:
> {code:groovy}
> // excerpt of org.apache.commons.lang3.tuple.Pair
> class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L, R>>, 
> Serializable {
>   public final L left
>   public final R right
>   private Pair(final L left, final R right) {
>     this.left = left
>     this.right = right
>   }
>   static <L, R> Pair<L, R> of(final L left, final R right) {
>     return new Pair<>(left, right)
>   }
>   L getKey() { left }
>   R getValue() { right }
>   R setValue(R value) { right }
>   int compareTo(Pair<L,R> that) { 0 }
> }
> @groovy.transform.TypeChecked
> def test(thing) {
>   thing != null ?: Pair.of('', ['']) // STCV is trying to get LUB of boolean 
> and Pair<String,List<String>>
> }
> test(null)
> {code}
> The problem appears in {{WideningCategories}}' {{lowestUpperBound}} and 
> {{parameterizeLowestUpperBound}}.
> Captured on Groovy 2.4.9:
> {code:java}
> java.lang.StackOverflowError
>       at org.codehaus.groovy.ast.ClassNode.getText(ClassNode.java:1686)
>       at org.codehaus.groovy.ast.ClassNode.equals(ClassNode.java:813)
>       at org.codehaus.groovy.ast.ClassNode.equals(ClassNode.java:810)
>       at 
> org.codehaus.groovy.ast.ClassNode.declaresInterface(ClassNode.java:1082)
>       at 
> org.codehaus.groovy.ast.ClassNode.implementsInterface(ClassNode.java:1060)
>       at 
> org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf(StaticTypeCheckingSupport.java:798)
>       at 
> org.codehaus.groovy.ast.tools.GenericsUtils.extractSuperClassGenerics(GenericsUtils.java:434)
>       at 
> org.codehaus.groovy.ast.tools.GenericsUtils.parameterizeType(GenericsUtils.java:228)
>       at 
> org.codehaus.groovy.ast.tools.WideningCategories.findGenericsTypeHolderForClass(WideningCategories.java:269)
>       at 
> org.codehaus.groovy.ast.tools.WideningCategories.parameterizeLowestUpperBound(WideningCategories.java:233)
>       at 
> org.codehaus.groovy.ast.tools.WideningCategories.lowestUpperBound(WideningCategories.java:203)
>       at 
> org.codehaus.groovy.ast.tools.WideningCategories.parameterizeLowestUpperBound(WideningCategories.java:250)
>       at 
> org.codehaus.groovy.ast.tools.WideningCategories.lowestUpperBound(WideningCategories.java:203)
>       at 
> org.codehaus.groovy.ast.tools.WideningCategories.parameterizeLowestUpperBound(WideningCategories.java:250)
>       at 
> org.codehaus.groovy.ast.tools.WideningCategories.lowestUpperBound(WideningCategories.java:203)
>       at 
> org.codehaus.groovy.ast.tools.WideningCategories.parameterizeLowestUpperBound(WideningCategories.java:250)
>       at 
> org.codehaus.groovy.ast.tools.WideningCategories.lowestUpperBound(WideningCategories.java:203)
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to