scala - Convert Class[_] to universe.Type/Symbol -
i'm trying list classes bundle , extract metadata info through new reflection api(2.10).
i may wrong, seems there no back upwards list classes bundle on scala api.
i'm using java library, returns class<?>
it possible convert class[_]
universe.type
or universe.symbol
?
you shoud utilize mirrors of scala.reflect.runtime.universe
(javauniverse)
suppose have runtime class:
val cls: class[_] = someobject.getclass
you should runtimemmirror
(javamirror) classloader , phone call classsymbol
method, converts runtime class classsymbol universe:
import scala.reflect.runtime._ val typ: universe.classsymbol = universe.runtimemirror(cls.getclassloader).classsymbol(cls)
scala reflection
No comments:
Post a Comment