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 classRepresents a class that can be loaded throughClassPath.ClassInfo.load().static classRepresents 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 ClassPathfrom(ClassLoader classloader) Returns aClassPathrepresenting all classes and resources loadable fromclassloaderand 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 ispackageNameor starts withpackageNamefollowed by a '.'.
-
Method Details
-
from
Returns aClassPathrepresenting all classes and resources loadable fromclassloaderand its parent class loaders.Warning: Currently only
URLClassLoaderand 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 ispackageNameor starts withpackageNamefollowed by a '.'.
-