[ https://issues.apache.org/jira/browse/GROOVY-11193?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17778122#comment-17778122 ]
Eric Milles commented on GROOVY-11193: -------------------------------------- You are compiling with the {{groovy-eclipse-compiler}} fixed at 3.0.8. You should be matching the version there with the version of Groovy you are targeting. You have stumbled upon the cross-compat issue for "super" that exists between 3 and 4. In order to fix a number of bugs with super, the arguments written at compile time for ScriptBytecodeAdapter.invokeMethodOnSuper are different in 4+. Thus when you compile with 3 and run with 4 the method indexing does not line up. As you noted, if you need to compile with a Groovy 3 compiler, then you should tag any method that makes a "super." method call with {{@CompileStatic}}. > Methods referenced by super cannot be found and are not executed > ---------------------------------------------------------------- > > Key: GROOVY-11193 > URL: https://issues.apache.org/jira/browse/GROOVY-11193 > Project: Groovy > Issue Type: Bug > Affects Versions: 4.0.0 > Reporter: Marek Parfianowicz > Assignee: Eric Milles > Priority: Major > Attachments: bug.zip > > > When one method calls another method from a parent class via {{super}} > keyword, the code is not executed at all. > I tested this in version 4.0.0 and 4.0.14 - in both it fails. (x) > It works correctly in 3.0.19. (/) > It also fails in 2.5.23, but with a runtime exception - > "{color:#172b4d}java.lang.AbstractMethodError" (x){color} > Code to reproduce: > > {code:java} > class MyClassBase { > void setUp() { > System.out.println("Called MyTestBase.setUp") > } > }{code} > > {code:java} > class MyClass extends MyClassBase { > void setUp() { > super.setUp() > System.out.println("Called MyTest.setUp") > } > static void main(String[] args) { > System.out.println("About to create MyClass") > MyClass my = new MyClass(); > my.setUp() > } > } {code} > Output for Groovy 4.0.14: > {noformat} > [INFO] --- exec-maven-plugin:3.0.0:java (default) @ bug --- > About to create MyClass > [WARNING] > groovy.lang.MissingMethodException: No signature of method: > MyClassBase.setUp() is applicable for argument types: () values: [] > Possible solutions: setUp(), getAt(java.lang.String), > tap(groovy.lang.Closure), sleep(long), sleep(long, groovy.lang.Closure), > dump() > at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap > (ScriptBytecodeAdapter.java:72) > at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN > (ScriptBytecodeAdapter.java:148) > at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0 > (ScriptBytecodeAdapter.java:166) > at MyClass.setUp (MyClass.groovy:3) > at MyClass$setUp.call (Unknown Source) > at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall > (CallSiteArray.java:45) > at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call > (AbstractCallSite.java:125) > at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call > (AbstractCallSite.java:130) > at MyClass.main (MyClass.groovy:10) > at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254) > at java.lang.Thread.run (Thread.java:750) > {noformat} > Please see the attached bug.zip sample project. > > Workaround: > Use {{@CompileStatic}} -- This message was sent by Atlassian Jira (v8.20.10#820010)