jeudi 6 juin 2019

Scala reflection: How to access the packages and objects under a package using runtime reflection

How do I access all the packages and classes under a given package using scala runtime reflection.

Lets say:

src
 - main
   - scala
    - com.my.package
     - packageone
        - packagetwo
           - First.scala
           - Second.scala

I have access to the package "com.my.package",

val p: universe.ModuleSymbol = scala.reflect.runtime.currentMirror.staticPackage("com.my.package")

Can I use this ModuleSymbol to iterate through the underlying packages and objects? Or is this even the correct starting point?

Appreciate any/all your inputs.





Aucun commentaire:

Enregistrer un commentaire