MethodScanner extracts method signatures from compiled .class
files without requiring the full runtime classpath. It uses ClassGraph to scan bytecode directly and works well even if classes depend on external frameworks like Spring or Servlet APIs.
- Recursively scans all
.class
files in a given directory (e.g.,target/classes
) - Extracts method names, parameter types (fully qualified), and return types
- Saves the output as a
.txt
file in a configurable or default location
- Older tools like Dependency Finder rely on class loading and full dependency resolution
- If classes reference external types (e.g.,
Validator
,HttpServletRequest
), those methods are not reported - This results in incomplete method coverage, in projects that depend on external frameworks.
While Dependency Finder supports a wide range of analysis tasks, this tool focuses specifically on method signature extraction:
- Uses ClassGraph, which reads
.class
files directly - No need to load classes, so it works even if referenced types are missing
- Extracts methods even from complex or framework-dependent classes, which were ignored by Dependency Finder
This tool solves the method extraction limitations you may have faced with Dependency Finder or reflection-based tools.
If you use the provided pom.xml
, ClassGraph will be automatically handled by Maven.
mvn compile
mvn exec:java -Dexec.mainClass="MethodScanner" -Dexec.args="path/to/target/classes"
You do NOT need to manually include ClassGraph in the classpath.
If you prefer to compile and run manually:
- Download
classgraph-4.8.162.jar
- Compile:
javac -cp classgraph-4.8.162.jar MethodScanner.java
- Run:
java -cp .:classgraph-4.8.162.jar MethodScanner path/to/target/classes
(Use ;
instead of :
on Windows)
org.springframework.samples.petclinic.web.PetController.processCreationForm(org.springframework.samples.petclinic.model.Pet, org.springframework.validation.BindingResult) : java.lang.String
org.springframework.samples.petclinic.web.VisitController.loadPetWithVisit(java.lang.Integer, java.util.Map<java.lang.String, java.lang.Object>) : void