groovy
  1. groovy
  2. GROOVY-4922

StackOverflowError when calling super and overriding a package protected java method

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.0
    • Fix Version/s: 2.0-beta-3, 1.7.11, 1.8.7
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      6

      Description

      For reference : http://groovy.329449.n5.nabble.com/StackOverflowError-when-dispatching-to-super-td4572268.html

      If a package protected method written in a Java class is overriden in a Groovy class and that method calls super.method(), Groovy throws a stack overflow :

      Parent.java
      class Parent {
         void someMethod(String param) { ... }
      }
      
      Child.groovy
      class Child {
         void someMethod(String param) { super.someMethod(param) }
      }
      
      java.lang.StackOverflowError
      	at java.lang.Exception.<init>(Exception.java:77)
      	at java.lang.reflect.InvocationTargetException.<init>(InvocationTargetException.java:54)
      	at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1054)
      	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:128)
      	at groovy.bugs.GroovyStackOverflowBug$Child.someMethod(GroovyStackOverflowBug.groovy:39)
      	at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1054)
      	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:128)
      	at groovy.bugs.GroovyStackOverflowBug$Child.someMethod(GroovyStackOverflowBug.groovy:39)
      	at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1054)
      	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:128)
      	at groovy.bugs.GroovyStackOverflowBug$Child.someMethod(GroovyStackOverflowBug.groovy:39)
      	at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
      ...
      

      Adding a public or protected modifier to the super class solves the problem.

      1. 4922failure.patch
        2 kB
        Hamlet D'Arcy
      2. GROOVY-4922.patch
        5 kB
        CÚdric Champeau
      3. GROOVY-4922-new.patch
        7 kB
        CÚdric Champeau
      4. test-reports.tar.gz
        329 kB
        CÚdric Champeau

        Activity

          People

          • Assignee:
            CÚdric Champeau
            Reporter:
            CÚdric Champeau
          • Votes:
            10 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: