In groovy, how do you dynamically call a static method of a class?
void callMethod(Class c, String staticmethodname){
//what goes here to call the static method of class c?
}
Voila
void callMethod(Class c, String staticmethodname){
c."$staticmethodname"()
}
class test {
static someMethod() {
println "me"
}
}
callMethod(test, "someMethod")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With