Details
-
Sub-task
-
Status: Open
-
Major
-
Resolution: Unresolved
-
2.1.9, 2.2.2, 2.4.0-beta-1, 2.3.5
-
None
Description
Method with argument of type Class cannot be found by metaClass.getMetaMethod():
class A { // cannot be found by getMetaMethod def met1(Class clazz) { println clazz.name } // a workaround def met2(List<Class> clazz) { println clazz.get(0).name } } A.metaClass.invokeMethod = { name, args -> def metaMethod = delegate.metaClass.getMetaMethod(name, args) if (metaMethod) { metaMethod.invoke(delegate, args) } else { println "Method $name not found on $delegate" } } def a = new A() a.met1(A) // prints Method met1 not found on A@1c804... a.met2([A]) // prints A
It could be caused by ambiguous nature of getMetaMethod which accepts array of Object or Class as well, in case of Class as an argument it cannot find method correctly.