I need to get the method parameter name in one of my scala files. I know, using the -parametercompiler option , I can do this job in Java. However, I cannot do this in scala, because I could not find the parameter-parameter in scalac.
How can i achieve this? I saw this answer in SO format, but this is an old answer. Is this not possible in scala (2.11), since this parameter appeared only in java8? Is there any hack for this?
EDIT: (adding a scala code sample)
class ReflectionTest {
def method(name: String, id: Long, desc: String) = {
println("Inside the method");
}
}
I am trying to read ReflectionTestclass method parametersmethod()
object Test extends App {
val methods= Class.forName("com.reflection.ReflectionTest").getMethods
methods filter(_.getName == "method") map { method =>
val param = method.getParameters
param.map {p =>
println("Method : "+method.getName+" , Parameter : "+p.getName)
}
}
}
Scala version: 2.11.2
JDK Version: 1.8
SBT Version: 0.13.1