Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
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 :
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.
Activity
Cedric Champeau
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Status | Open [ 1 ] | In Progress [ 3 ] |
Cedric Champeau
made changes -
| 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 : {code:title=Parent.java} class Parent { void someMethod(String param) { ... } } {code} {code:title=Child.groovy} class Child { void someMethod(String param) { super.someMethod(param) } } {code} {code] 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) ... {code} Adding a public or protected modifier to the super class solves the problem. |
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 : {code:title=Parent.java} class Parent { void someMethod(String param) { ... } } {code} {code:title=Child.groovy} class Child { void someMethod(String param) { super.someMethod(param) } } {code} {code} 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) ... {code} Adding a public or protected modifier to the super class solves the problem. |
Cedric Champeau
made changes -
| Attachment | GROOVY-4922.patch [ 56029 ] | |
| Attachment | test-reports.tar.gz [ 56030 ] |
Cedric Champeau
made changes -
| Attachment | GROOVY-4922-new.patch [ 56031 ] |
blackdrag blackdrag
made changes -
| Status | In Progress [ 3 ] | Closed [ 6 ] |
| Assignee | Cedric Champeau [ melix ] | Jochen Theodorou [ blackdrag ] |
| Fix Version/s | 1.7.11 [ 17244 ] | |
| Fix Version/s | 1.8.1 [ 17223 ] | |
| Resolution | Fixed [ 1 ] |
Hamlet D'Arcy
made changes -
| Resolution | Fixed [ 1 ] | |
| Status | Closed [ 6 ] | Reopened [ 4 ] |
Hamlet D'Arcy
made changes -
| Attachment | 4922failure.patch [ 56041 ] |
Guillaume Laforge
made changes -
| Assignee | Jochen Theodorou [ blackdrag ] | Guillaume Laforge [ guillaume ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.9-beta-1 [ 17153 ] | |
| Fix Version/s | 1.7.11 [ 17244 ] |
Guillaume Laforge
made changes -
| Status | Reopened [ 4 ] | Resolved [ 5 ] |
| Resolution | Fixed [ 1 ] |
Guillaume Laforge
made changes -
| Resolution | Fixed [ 1 ] | |
| Status | Resolved [ 5 ] | Reopened [ 4 ] |
| Assignee | Guillaume Laforge [ guillaume ] | Cedric Champeau [ melix ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.7.11 [ 17244 ] |
Hamlet D'Arcy
made changes -
| Attachment | stackoverflow-example.zip [ 56082 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.8.2 [ 17495 ] | |
| Fix Version/s | 1.8.1 [ 17223 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.9-beta-2 [ 17494 ] | |
| Fix Version/s | 1.9-beta-1 [ 17153 ] |
Hamlet D'Arcy
made changes -
| Attachment | new_stackoverflow_example.zip [ 56088 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.8.3 [ 17657 ] | |
| Fix Version/s | 1.8.2 [ 17495 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.9-beta-4 [ 17656 ] | |
| Fix Version/s | 1.9-beta-3 [ 17494 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.8.4 [ 17852 ] | |
| Fix Version/s | 1.8.3 [ 17657 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.9-beta-5 [ 17925 ] | |
| Fix Version/s | 1.9-beta-4 [ 17656 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.8.5 [ 18071 ] | |
| Fix Version/s | 1.8.4 [ 17852 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 2.0-beta-2 [ 18072 ] | |
| Fix Version/s | 2.0-beta-1 [ 17925 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.8.6 [ 18245 ] | |
| Fix Version/s | 1.8.5 [ 18071 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 2.0-beta-3 [ 18244 ] | |
| Fix Version/s | 2.0-beta-2 [ 18072 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.8.7 [ 18317 ] | |
| Fix Version/s | 1.8.6 [ 18245 ] |
blackdrag blackdrag
made changes -
| Link |
This issue is depended upon by |
Cedric Champeau
made changes -
| Link |
This issue is depended upon by |
Cedric Champeau
made changes -
| Status | Reopened [ 4 ] | Resolved [ 5 ] |
| Resolution | Fixed [ 1 ] |
Paul King
made changes -
| Status | Resolved [ 5 ] | Closed [ 6 ] |
Here is what I found. In MetaClassImpl.MethodIndexAction#methodNameAction(),
So it seems there are two problems to solve : the fact that the super method is missing from the MOP methods and the test which forgets about package protected methods. I'm not sure this can be fixed without side effects.