I have a class name and a method whose type parameters I know, and I\'d like to invoke this method via reflection.
In java I\'d do something like:
Cl
Refer scala doc reflection overview
// get runtime universe
val ru = scala.reflect.runtime.universe
// get runtime mirror
val rm = ru.runtimeMirror(getClass.getClassLoader)
// define class and companion object
class Boo{def hey(x: Int) = x}; object Boo{def hi(x: Int) = x*x}
// get instance mirror for companion object Boo
val instanceMirror = rm.reflect(Boo)
// get method symbol for the "hi" method in companion object
val methodSymbolHi = ru.typeOf[Boo.type].decl(ru.TermName("hi")).asMethod
// get method mirror for "hi" method
val methodHi = instanceMirror.reflectMethod(methodSymbolHi)
// invoke the method "hi"
methodHi(4) // 16