How adrninistrator/java-all-call-graph works
Main Components
a. Input Module – Source Code Scanner:
• This module is responsible for reading Java source or compiled classes.
• It may include file system traversal logic and initial filtering that leads the tool to process certain packages or files.
b. Call Graph Extraction Engine:
• The heart of the system, which parses the code (or bytecode), extracts method call relationships, and handles specialized scenarios like recursive calls, loops, or even filtering based on configuration.
• Within the project, the package structure under “src/main/java/com/adrninistrator/jacg/extractor” and “src/main/java/com/adrninistrator/jacg/runner” are central to this functionality.
c. Analysis and Handler Subsystems:
• There are multiple “handler” packages (for annotations, classes, method calls, field relationships, etc.) that process, validate, and format the extracted data.
• They implement strategies for dealing with edge cases (e.g., cyclic calls, lambda expressions, annotation specifics) and support extensibility.
d. Configuration and Extension Management:
• The system uses configuration files (found in resource directories like “_jacg_config” and “_jacg_extensions”) which govern filtering rules, output details, and custom extensions.
• Additionally, the project supports extension points – allowing users to plug in custom code to modify extraction or output behavior.
e. Output/Storage Module:
• This component formats and organizes the extracted call graph data (e.g., as JSON, SQL insertions, or files) for generating reports or visual representations.
• Integration with databases is supported (refer to the “SQL语句” directory with SQL scripts and “neo4j” packages for graph database output).
f. External Integration Interfaces:
• Integration with external systems such as Neo4j is evident from dedicated modules for graph database operation.
• There are also runner scripts (shell, Gradle build files) and test cases that demonstrate command-line execution and integration.
Establish Relationships and Interactions
• Flow starting from the source code input, which feeds into the extraction and parsing engine.
• The extracted method call data is passed to various handler modules that process and filter the raw data.
• Processed data is directed to output modules where it can be written directly to files, inserted into SQL databases, or sent to a Neo4j graph database.
Important Architectural Patterns
• Existence of “Extension” points that follow Strategy or Plugin patterns, allowing custom behaviors for annotation parsing, filtering, or method call transformation.
• Separation of concerns is visible: the code is organized by functionality (e.g., extraction tasks vs. database writing tasks) and by runtime environment (source vs. test resources).
Technologies and Frameworks
• Gradle is used as the build tool – include a small note that the build configuration manages dependencies.
• For data persistence and graph representation, integration with SQL databases and Neo4j is central.
• Java itself is the primary language, and parts of the system likely leverage reflection and bytecode reading libraries.
Detail on Essential Architectural Elements
• Clearly split the system into as many logical components as possible. Even sub-packages should have their own representation if they play a distinct role.
• Interfaces and abstract classes where strategy or dependency injection is in use.
• Optionally, include testing infrastructure separately to demonstrate how automated tests validate core functionalities.