I need to get a method's parameter name in one of my scala file. I know, by using -parameter
compiler option, I can make this work in Java. However, I am not able to do this in scala,as I could not find -parameter option in scalac.
How can I achieve this ? I saw this answer in SO, but it is an old answer. Is it not possible in scala(2.11) as this option has come only in java8? Is there any hack for it ?
EDIT: (adding sample scala code)
class ReflectionTest {
def method(name: String, id: Long, desc: String) = {
println("Inside the method");
}
}
I am trying to read the method parameters of ReflectionTest
class's method()
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