ronmamo / reflections
Java runtime metadata analysis
AI Architecture Analysis
This repository is indexed by RepoMind. By analyzing ronmamo/reflections in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.
Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.
Repository Overview (README excerpt)
Crawler view*❗ Please note: Reflections library is currently NOT under active development or maintenance ❗* *Thank you for your continuous support! There are open issues and also workarounds. Release version will be considered incase contributing PR fixing the main issues.* *Last released (Oct 2021)* ---- Java runtime metadata analysis Reflections scans and indexes your project's classpath metadata, allowing reverse transitive query of the type system on runtime. Using Reflections you can query for example: • Subtypes of a type • Types annotated with an annotation • Methods with annotation, parameters, return type • Resources found in classpath And more... *Reflections was written in the spirit of Scannotations library* Usage Add Reflections dependency to your project: Create Reflections instance and use the query functions: Or using previous 0.9.x APIs, for example: *Note that there are some breaking changes with Reflections 0.10+, along with performance improvements and more functional API, see below.* Scan Creating Reflections instance requires ConfigurationBuilder, typically configured with packages and Scanners to use: Other examples: Note that: • **Scanner must be configured in order to be queried, otherwise an empty result is returned** If not specified, default scanners will be used SubTypes, TypesAnnotated. For all standard scanners use . See more scanners in the source package. • **All relevant URLs should be configured** Consider in case too many classes are scanned. If required, Reflections will expand super types) in order to get the transitive closure metadata without scanning large 3rd party urls. • Classloader can optionally be used for resolving runtime classes from names. Query Once Reflections was instantiated and scanning was successful, it can be used for querying the indexed metadata. More scanners: *See more examples in ReflectionsQueryTest.* *Note that previous 0.9.x APIs are still supported* Compare Scanners and previous 0.9.x API (*) | Scanners | previous 0.9.x API | previous Scanner | | -------- | ------------------ | ------ | | | getSubTypesOf(T) | ~~SubTypesScanner~~ | | | getTypesAnnotatedWith(A) *(1)*| ~~TypeAnnotationsScanner~~ | | | getMethodsAnnotatedWith(A) | ~~MethodAnnotationsScanner~~ | | | getConstructorsAnnotatedWith(A) *(2)*| ~~MethodAnnotationsScanner~~ | | | getFieldsAnnotatedWith(A) | ~~FieldAnnotationsScanner~~ | | | getResources(regex) | ~~ResourcesScanner~~ | | | getMethodsWithParameter(P) *(3)* ~~getMethodsWithAnyParamAnnotated(P)~~| ~~MethodParameterScanner~~ *obsolete* | | | getMethodsWithSignature(P, ...) *(3) ~~getMethodsMatchParams(P, ...)~~*| " | | | getMethodsReturn(T) *(3)*| " | | | getConstructorsWithParameter(P) *(3) ~~getConstructorsWithAnyParamAnnotated(P)~~*| " | | | getConstructorsWithSignature(P, ...) *(3) ~~getConstructorsMatchParams(P, ...)~~*| " | *Note: and mappings were omitted* *(1): The equivalent of is , including SubTypes* *(2): MethodsAnnotatedScanner does not include constructor annotation scanning, use instead Scanners.ConstructorsAnnotated* *(3): MethodParameterScanner is obsolete, use instead as required: Scanners.MethodsParameter, Scanners.MethodsSignature, Scanners.MethodsReturn, Scanners.ConstructorsParameter, Scanners.ConstructorsSignature* ReflectionUtils Apart from scanning classpath metadata using Javassist, Java Reflection convenient methods are available using ReflectionsUtils: *Previous ReflectionUtils 0.9.x API is still supported though marked for removal, more info in the javadocs.* Query API Each Scanner and ReflectionUtils function implements QueryBuilder, and supports: • - function returns direct values • or - function returns all transitive values *For example, return direct subtypes, while return transitive subtypes hierarchy. Same goes for and etc.* Next, each function implements QueryFunction, and provides fluent functional interface for composing , , , and more, such that: See more in ReflectionUtilsQueryTest A more complex example demonstrates getting merged annotations of rest controllers endpoints: Check the tests folder for more examples and API usage What else? • **Integrating with build lifecycle** It is sometime useful to the scanned metadata into xml/json as part of the build lifecycle for generating resources, and then collect it on bootstrap with and avoid scanning. *See reflections-maven for example*. • JavaCodeSerializer - scanned metadata can be persisted into a generated Java source code. Although less common, it can be useful for accessing types and members in a strongly typed manner. *(see example)* • AnnotationMergeCollector - can be used to merge similar annotations. *(see test)* • - experimental scanner allow querying for member usages of packages/types/elements in the classpath. Can be used for finding usages between packages, layers, modules, types etc. ---- *Spread the spirit of open-source and collaboration, clean code and simplicity*