Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala 2.10 and package reflection

How can I reflect over package hierarchies in Scala 2.10's reflection? Can I find out what subpackages exist, or what the parent packages are?

like image 537
Daniel C. Sobral Avatar asked Jun 30 '12 19:06

Daniel C. Sobral


1 Answers

Since in general case it's impossible to enumerate packages in a classloader, Scala reflection also doesn't provide this capability. This is unlike the situation with scalac, which is fed a list of directories, which can be enumerated.

Traversing up the hierarchy is easy. Just use symbol.owner.

like image 151
Eugene Burmako Avatar answered Oct 01 '22 19:10

Eugene Burmako