Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.8.0
Description
I have a class with static utility methods. I have done 'mixin' this class into another class using @Mixin annotation and then while calling static overloaded method I give runtime error.
Utility class:
class UtilClass { public void callClassOverloadedMethod(String s) { System.out.println("callClassOverloadedMethod(String)"); } public void callClassOverloadedMethod(String s, Object o) { System.out.println("callClassOverloadedMethod(String, Object)"); } public static void callStaticOverloadedMethod(String s) { System.out.println("callStaticOverloadedMethod(String)"); } public static void callStaticOverloadedMethod(String s, Object o) { System.out.println("callStaticOverloadedMethod(String, Object)"); } }
Main class:
@Mixin(UtilClass) class MainClass { public static void main(String []s) { MainClass mc = new MainClass() mc.callMixinMethods() } void callMixinMethods() { callClassOverloadedMethod("") callStaticOverloadedMethod("") } }
Run command:
groovy -cp . MainClass
Error:
Caught: org.codehaus.groovy.runtime.metaclass.MethodSelectionException: Could not find which method callStaticOverloadedMethod() to invoke from this list: public static void UtilClass#callStaticOverloadedMethod(java.lang.String) public static void UtilClass#callStaticOverloadedMethod(java.lang.String, java.lang.Object) at MainClass.callMixinMethod(MainClass.groovy:20) at MainClass.main(MainClass.groovy:12)
Please fix this trouble, it prevent me to write code and tests.