Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-4922

StackOverflowError when calling super and overriding a package protected java method

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.0
    • 2.0-beta-3, 1.7.11, 1.8.7
    • None
    • None

    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.

      Attachments

        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. new_stackoverflow_example.zip
          35 kB
          Hamlet D'Arcy
        5. stackoverflow-example.zip
          10 kB
          Hamlet D'Arcy
        6. test-reports.tar.gz
          329 kB
          Cédric Champeau

        Activity

          People

            melix Cédric Champeau
            melix Cédric Champeau
            Votes:
            10 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: