Can you find all classes in a package using reflection?

前端 未结 27 2265
不知归路
不知归路 2020-11-21 05:24

Is it possible to find all classes or interfaces in a given package? (Quickly looking at e.g. Package, it would seem like no.)

27条回答
  •  青春惊慌失措
    2020-11-21 05:49

    Google Guava 14 includes a new class ClassPath with three methods to scan for top level classes:

    • getTopLevelClasses()
    • getTopLevelClasses(String packageName)
    • getTopLevelClassesRecursive(String packageName)

    See the ClassPath javadocs for more info.

提交回复
热议问题