[
https://issues.apache.org/jira/browse/GROOVY-11193?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Marek Parfianowicz updated GROOVY-11193:
----------------------------------------
Description:
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}}
was:
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.
> 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
> 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)