Package com.google.common.reflect
Class ClassPath
java.lang.Object
com.google.common.reflect.ClassPath
Scans the source of a
ClassLoader
and finds all loadable classes and resources.
Warning: Currently only URLClassLoader
and only file://
urls are
supported.
- Since:
- 14.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Represents a class that can be loaded throughClassPath.ClassInfo.load()
.static class
Represents a class path resource that can be either a class file or any other resource file loadable from the class path. -
Method Summary
Modifier and TypeMethodDescriptionstatic ClassPath
from
(ClassLoader classloader) Returns aClassPath
representing all classes and resources loadable fromclassloader
and its parent class loaders.Returns all classes loadable from the current class path.Returns all resources loadable from the current class path, including the class files of all loadable classes but excluding the "META-INF/MANIFEST.MF" file.Returns all top level classes loadable from the current class path.getTopLevelClasses
(String packageName) Returns all top level classes whose package name ispackageName
.getTopLevelClassesRecursive
(String packageName) Returns all top level classes whose package name ispackageName
or starts withpackageName
followed by a '.'.
-
Method Details
-
from
Returns aClassPath
representing all classes and resources loadable fromclassloader
and its parent class loaders.Warning: Currently only
URLClassLoader
and onlyfile://
urls are supported.- Throws:
IOException
- if the attempt to read class path resources (jar files or directories) failed.
-
getResources
Returns all resources loadable from the current class path, including the class files of all loadable classes but excluding the "META-INF/MANIFEST.MF" file. -
getAllClasses
Returns all classes loadable from the current class path.- Since:
- 16.0
-
getTopLevelClasses
Returns all top level classes loadable from the current class path. -
getTopLevelClasses
Returns all top level classes whose package name ispackageName
. -
getTopLevelClassesRecursive
Returns all top level classes whose package name ispackageName
or starts withpackageName
followed by a '.'.
-