How do you reflect a case class's members at run time without an instance?
For example if I have the following case class:
package com.abc
object Holder {
case class Hello(message:String,count:Int)
}
I would of thought although I don't have an instance of Hello to reflect I could reflect the Companion Object apply method and inspect the arguments to know about what members it has?
val mirror = ru.runtimeMirror(getClass.getClassLoader)
val module = mirror.staticModule("com.abc.Holder$Hello")
val instance = mirror.reflectModule(module).symbol.typeSignature.member(TermName("apply")).asMethod.paramLists
instance.foreach(println)
However this returns "none" is not a method. So it doesn't have an apply method?
Aucun commentaire:
Enregistrer un commentaire