I'm trying to list all classes from a package and extract some metadata information through the new reflection api(2.10).
I may be wrong, but seems that there is no support to list classes from a package on the scala api.
I'm using a java library, but it returns only the Class<?>
It is possible to convert a Class[_]
to universe.Type
or universe.Symbol
?
You shoud use mirrors of scala.reflect.runtime.universe
(JavaUniverse)
Suppose you have a runtime class:
val cls: Class[_] = someObject.getClass
You should get runtimeMmirror
(JavaMirror) for your classloader and call its classSymbol
method, which converts runtime class to ClassSymbol for this universe:
import scala.reflect.runtime._
val typ: universe.ClassSymbol = universe.runtimeMirror(cls.getClassLoader).classSymbol(cls)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With