Sounds like you want the --parameters
(alias -pa
) compiler argument.
Generates metadata for reflection on method parameter names on JDK 8 and above. Defaults to false.
Usage: groovy --parameters Person.groovy
Also available for groovyc
, groovyConsole
, groovysh
and groovy ant tasks
. Check out the PR some awesome person contributed...
e.g.
class HelloWorld {
static void speak(String firstName) {
println "Hello $firstName"
}
}
Student.methods.each {
if (it.name === 'speak') println it.parameters
}
// groovy HelloWorld.groovy => "[java.lang.String arg0]"
// groovy -pa HelloWorld.groovy => "[java.lang.String firstName]"