You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Optionally call .verbose() to enable verbose logging to stderr.
Enable classfile scanning, if you want to scan classes -- in the simplest case, call .enableAllInfo() to enable the scanning of classes, methods, fields, and annotations.
Call .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.
💡 The ScanResult should be assigned in a try-with-resources block or equivalent. See ScanResult lifecycle.
Query the ScanResult object: (the ScanResult object can be queried repeatedly without re-running the scan)
For class scan results: Call methods such as .getAllClasses(), .getAllInterfaces() etc. to get ClassInfoList lists of ClassInfo objects for classes of interest
Query the ClassInfo objects for class properties or class relationships of interest.
Call ClassInfo#getMethodInfo() to get info on the methods of the class as a MethodInfoList of MethodInfo objects.
Call MethodInfo#getMethodParameterInfo() to get info on the parameters of a method as an array of MethodParameterInfo objects, one per parameter.
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.
And/or for resource scan results: Call methods such as .getAllResources(), .getResourcesWithPath(path), .getResourcesWithExtension(ext) etc. to get ResourceList lists of Resource (file) objects matching a given path or filename pattern.
Call methods 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.
(The method metadata class. Use MethodInfo objects to obtain references to MethodParameterInfo objects, and/or AnnotationInfo objects for method annotations.)
(The method parameter metadata class. Use MethodParameterInfo objects to obtain references to AnnotationInfo objects for method parameter annotations.)
(The annotation metadata class. Use AnnotationInfo objects to obtain references to AnnotationParameterValue objects for parameter values for specific annotation instances.)
Documentation for legacy API (FastClasspathScanner)
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.