Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
sample code to invoke ReflectionMethodInvoker of groovy
import org.codehaus.groovy.runtime.ReflectionMethodInvoker
class Base{}
class Derived extends Base{}
class Derived2 extends Derived{}
class Hello{
public void hello(Base b){
println "base"
public void hello(Derived d){
println "derived";
h = new Hello()
ReflectionMethodInvoker.invoke(h, "hello", new Base())
ReflectionMethodInvoker.invoke(h, "hello", new Derived())
ReflectionMethodInvoker.invoke(h, "hello", new Derived2())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment