An ultra-fast parallelized classpath and module scanner for JVM languages that indexes class metadata without loading classes.
ClassGraph is an ultra-fast, parallelized classpath and module scanner for JVM languages like Java, Scala, and Kotlin. It builds a queryable graph of class metadata (classes, annotations, methods, fields) without loading the classes themselves, solving the problem of discovering and analyzing code structure at runtime or build time. It inverts the standard Java reflection API, allowing developers to find all classes that match specific criteria, such as those with certain annotations or implementing particular interfaces.
Java, Scala, and Kotlin developers who need to perform runtime or build-time code analysis, annotation processing, dependency injection, framework development, or plugin system implementation.
Developers choose ClassGraph for its exceptional speed due to parallelized scanning, its comprehensive support for both classpath and module path across JDK versions, and its powerful query capabilities that go beyond standard reflection. It is a mature, award-winning library with no dependencies and handles more edge cases in classpath specification than alternatives.
An uber-fast parallelized Java classpath scanner and module scanner.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses carefully optimized multithreading to achieve scan speeds near I/O bandwidth limits, making it significantly faster than many alternatives.
Fully compatible with both traditional classpaths and the JPMS module system (JDK 9+), while maintaining backwards compatibility with JDK 7 and 8, as stated in the README.
Inverts the standard reflection API to enable queries like finding all subclasses or annotated classes without loading them, enabling advanced metaprogramming.
Can find and load resources matching patterns across all classloaders and modules, such as JSON files in META-INF/config, as shown in the code examples.
Requires extra libraries like Narcissus or JVM-Driver to bypass strong encapsulation on JDK 16+, adding dependency and setup complexity, as admitted in the README.
Building an in-memory graph of all class metadata can be memory-intensive for applications with vast numbers of classes, a trade-off for fast querying.
Generating GraphViz visualizations depends on an external tool, which may not be integrated into all development workflows and adds an extra step.