See also the code examples page.
new ClassGraph()
instance, and configure it for scanning:
.verbose()
to enable verbose logging to stderr..enableAllInfo()
to enable the scanning of classes, methods, fields, and annotations..acceptPackages(String... packages)
to accept specific packages to scan, or .acceptPaths(String... paths)
if you only want to scan resources and not classes. If you don't call either of these methods, then all packages or paths will be scanned..scan()
, to produce a ScanResult
object.
💡 The
ScanResult
should be assigned in a try-with-resources block or equivalent. SeeScanResult
lifecycle.
ScanResult
object: (the ScanResult
object can be queried repeatedly without re-running the scan)
.getAllClasses()
, .getAllInterfaces()
etc. to get ClassInfoList
lists of ClassInfo
objects for classes of interest
ClassInfo
objects for class properties or class relationships of interest.
ClassInfo#getMethodInfo()
to get info on the methods of the class as a MethodInfoList
of MethodInfo
objects.
MethodInfo#getMethodParameterInfo()
to get info on the parameters of a method as an array of MethodParameterInfo
objects, one per parameter.MethodInfo#getAnnotationInfo()
to get the annotations on a method as an AnnotationInfoList
of AnnotationInfo
objects.ClassInfo#getFieldInfo()
to get info on the fields of a class as a FieldInfoList
of FieldInfo
objects.
FieldInfo#getAnnotationInfo()
to the annotations on a field as an AnnotationInfoList
of AnnotationInfo
objects.ClassInfo#getAnnotationInfo()
to get the annotations on a class as an AnnotationInfoList
of AnnotationInfo
objects.ClassInfoList
lists can be filtered using .filter(predicateFunction)
or combined using .union(ClassInfoList... others)
, .intersect(ClassInfoList... others)
, or .exclude(ClassInfoList other)
, to return a new ClassInfoList
representing the predicate-filtered subset, union, intersection or set difference respectively..getAllResources()
, .getResourcesWithPath(path)
, .getResourcesWithExtension(ext)
etc. to get ResourceList
lists of Resource
(file) objects matching a given path or filename pattern.
ResourceList#forEachByteArray(ByteArrayConsumer)
and similar functions to open the content of each Resource
object as a ByteBuffer
or InputStream
, or read the complete contents into a byte[]
array, then pass the buffer, stream or array to a consumer method, closing the buffer or stream when the consumer exits.You can scan either at runtime (the normal usecase), or at build time (for faster startup speed, or to support Android, since it does not use the standard Java bytecode format).
See the code examples page for specific examples of how to use the ClassGraph API.
ClassGraph
instanceClassInfo
ClassInfo
objects to obtain references to AnnotationInfo
, MethodInfo
, MethodParameterInfo
or FieldInfo
objects.)ClassInfoList
MethodInfo
MethodInfo
objects to obtain references to MethodParameterInfo
objects, and/or AnnotationInfo
objects for method annotations.)MethodParameterInfo
MethodParameterInfo
objects to obtain references to AnnotationInfo
objects for method parameter annotations.)MethodInfoList
FieldInfo
FieldInfo
objects to obtain references to AnnotationInfo
objects for field annotations.)FieldInfoList
AnnotationInfo
AnnotationInfo
objects to obtain references to AnnotationParameterValue
objects for parameter values for specific annotation instances.)AnnotationParameterValue
AnnotationEnumValue
AnnotationClassRef
AnnotationInfoList
Resource
ResourceList
ClassGraph version 4 is a major upgrade over the previous version, FastClasspathScanner version 3, and there were a number of major API changes between FastClasspathScanner and ClassGraph. See here for information on porting FastClasspathScanner v3 code to the ClassGraph v4 API, and for info on how to obtain the older FastClasspathScanner version 3 documentation.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4