A Java annotation processor that collects method-level metadata during compilation and generates a registry class for runtime access.
- scans compiled source units in annotation-processing rounds
- inspects discovered classes and methods
- extracts a lightweight method signature/source line hint
- generates
MethodRegistrywithMethodInfoentries
The generated registry can be used by downstream tooling for search, retrieval, traceability, or explanation workflows.
This repository is a working prototype.
- implemented: core annotation processor and generated registry output
- implemented: service registration for
javax.annotation.processing.Processor - pending: robust method-source extraction (currently naive string matching)
- pending: richer model conversion (
JsonConverter, helper models)
src/main/java/org/wseresearch/source_code_retrieval/SourceCodeProcessor.java- annotation processorsrc/main/java/org/wseresearch/source_code_retrieval/MethodInfo.java- metadata modelsrc/main/resources/META-INF/services/javax.annotation.processing.Processor- processor registrationsrc/test/java/.../SourceCodeRetrievalApplicationTests.java- baseline test scaffold
./mvnw clean testAdd dependency:
<dependency>
<groupId>org.wseresearch</groupId>
<artifactId>source-code-retrieval</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>Configure the compiler plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.wseresearch</groupId>
<artifactId>source-code-retrieval</artifactId>
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>After compilation, inspect generated sources under your Maven generated-sources directory for MethodRegistry.
- Java compatibility in
pom.xmlcurrently mixes Spring Boot 3.x and explicit compiler source/target values; align this before publishing. - For production-grade extraction, replace naive line matching with parser-based extraction (e.g., JavaParser).