Find every class that extends a base class or implements an interface without manually scanning files.
Build plugin systems that automatically discover and load components present in the project.
Support dependency injection frameworks that wire together components without explicit config files.
Create testing tools that locate all classes or methods tagged with a specific annotation.
Add a single Maven or Gradle dependency for version 0.10.2. Note: the project is no longer actively maintained, so no new releases or bug fixes should be expected.
Reflections is a Java library that lets a program ask questions about its own code at runtime. In Java, every class, method, and annotation is described by metadata that the language keeps around while a program is running. Normally accessing this information requires writing a lot of boilerplate code. Reflections scans all the classes in a project and builds a searchable index of that metadata, so developers can look things up with simple queries instead. For example, a developer might want to find every class that extends a particular base class, every method tagged with a certain annotation, or every class that implements a specific interface. Without a library like Reflections, this requires walking through every file manually. With it, a single line of code returns the set of matching items. This is useful for building plugin systems, dependency injection frameworks, testing tools, and any code that needs to discover and load components dynamically based on what is present in the project. The library is configured by telling it which packages to scan and which types of metadata to index. You can choose to index only subtype relationships, only annotated types, only annotated methods, or all of the above. Once the scan is done, the index is queried using a fluent API where you chain together conditions to describe what you want. Results can be returned as Class objects, Method objects, Field objects, or strings depending on what you asked for. Reflections is added to a Java project through Maven or Gradle with a single dependency line. The last stable release was version 0.10.2 in October 2021. The README notes clearly that the project is not currently under active development or maintenance, though the code remains available and prior releases continue to work. The library is widely used in the Java ecosystem, particularly by frameworks and tools that need to discover and wire together components without requiring developers to list them explicitly in a configuration file.
← ronmamo on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.