[ 
https://issues.apache.org/jira/browse/GROOVY-11193?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17778422#comment-17778422
 ] 

Eric Milles commented on GROOVY-11193:
--------------------------------------

[~marek-parfianowicz] You only need to SC the method(s) that make super calls.  
In case this is an easier transition.

[~blackdrag] This applies to {{groovyc}} as well.  It is just much harder to 
setup Gradle or Maven to use one version of Groovy for compilation and another 
for test execution.  The incompatibility was discovered after the Groovy 4 
release and at that time, I marked a couple issue tickets as breaking.  I don't 
think anything was added to the release notes post release.

Once it was in the wild, I tried to think how we might detect a Groovy 
less-than-4 caller of {{invokeMethodOnSuperN}} but didn't come up with 
anything.  If there is a way to do so, we could still add something to smooth 
this over.

> 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)

Reply via email to