Java Language Support
Java Language Support
Section titled “Java Language Support”This document describes the Java language parsing support in Arxo.
Overview
Section titled “Overview”Arxo supports analyzing Java codebases, extracting import graphs, call graphs, and detecting side effects. Java support works alongside TypeScript, Rust, and Python support, enabling analysis of mixed-language projects. Parsing uses tree-sitter (tree-sitter-java).
Features
Section titled “Features”Import Graph Analysis
Section titled “Import Graph Analysis”importstatements: Extractsimport com.example.Foo;,import com.example.*;,import static com.example.Util.helper;packagedeclarations: Tracks package boundaries for module resolution- Public types: Detects public class, interface, and enum declarations for exports
- Module resolution: Resolves Java package paths to file paths:
com.example.foo→com/example/foo.javaorcom/example/Foo.java- Follows Maven/Gradle source layout (
src/main/java, etc.) when present
Call Graph Analysis
Section titled “Call Graph Analysis”- Method calls: Tracks instance and static method invocations (e.g.,
obj.method(),Util.helper()) - Constructor calls: Extracts
new Foo()and chained constructors - Type resolution: Resolves method and constructor targets using class hierarchy and package index
Effect Detection
Section titled “Effect Detection”Detects side effects in Java code:
- I/O:
java.io.*,java.nio.file.*,File,FileReader,FileWriter,InputStream,OutputStream,Files,Paths - Network:
java.net.*,Socket,ServerSocket,URL,HttpURLConnection,HttpClient - Storage:
java.sql.*,Connection,Statement,execute,commit - Logging:
java.util.logging,System.out,System.err,println,print,log - Time:
System.currentTimeMillis,Instant,LocalDateTime, time-related APIs - Random:
Random,SecureRandom,Math.random - Mutation: Shared mutable state patterns
Configuration
Section titled “Configuration”Language Selection
Section titled “Language Selection”You can specify the language in your config file:
data: language: java # Options: "typescript", "rust", "python", "java", or "auto" import_graph: group_by: folder group_depth: 2 exclude: - target - build - out - .gradle - node_modulesAuto-Detection
Section titled “Auto-Detection”If language: auto is specified (the default), Arxo will:
- Scan the project directory for file extensions
- Detect which languages are present (
.javafor Java,.pyfor Python,.rsfor Rust,.ts/.tsxfor TypeScript) - Parse all detected languages and merge their graphs
Mixed-Language Projects
Section titled “Mixed-Language Projects”Arxo supports analyzing projects with Java and other languages:
data: language: auto import_graph: exclude: - target - build - out - __pycache__ - node_modulesModule Resolution
Section titled “Module Resolution”Java module resolution follows these rules:
- Package to path: Fully qualified names (e.g.
com.example.Foo) map to paths under source roots (src/main/java,src, etc.):com/example/Foo.java. - Source roots: Common layouts (Maven
src/main/java, Gradlesrc/main/java, plainsrc) are discovered; all.javafiles under them are included. - Standard library and third-party JARs: Not resolved; no edges are added for types outside the project source tree.
Limitations
Section titled “Limitations”- Reflection:
Class.forName(), reflection-based invocation, and dynamic proxies are not analyzed. - Annotations and code generation: Generated code (e.g. from annotation processors) is not analyzed unless source is present.
- External dependencies: Types from JARs are treated as external; only project
.javasources are included in the graph. - Lambdas and method references: Resolution may be best-effort for complex functional call chains.
Running Analysis
Section titled “Running Analysis”arxo analyze --path /path/to/java/project --config your-config.yamlFor JSON output (e.g. for scripting or CI):
arxo analyze --path /path/to/java/project --config your-config.yaml --jsonRelated Documentation
Section titled “Related Documentation”- Metrics Documentation — All metrics work with Java code
- Plugin Development — Create custom metrics
- Configuration — General configuration options
- Rust Support — Rust language support
- Python Support — Python language support