Skip to content
Arxo Arxo

Java Language Support

This document describes the Java language parsing support in Arxo.

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).

  • import statements: Extracts import com.example.Foo;, import com.example.*;, import static com.example.Util.helper;
  • package declarations: 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.foocom/example/foo.java or com/example/Foo.java
    • Follows Maven/Gradle source layout (src/main/java, etc.) when present
  • 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

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

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_modules

If language: auto is specified (the default), Arxo will:

  1. Scan the project directory for file extensions
  2. Detect which languages are present (.java for Java, .py for Python, .rs for Rust, .ts/.tsx for TypeScript)
  3. Parse all detected languages and merge their graphs

Arxo supports analyzing projects with Java and other languages:

data:
language: auto
import_graph:
exclude:
- target
- build
- out
- __pycache__
- node_modules

Java module resolution follows these rules:

  1. 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.
  2. Source roots: Common layouts (Maven src/main/java, Gradle src/main/java, plain src) are discovered; all .java files under them are included.
  3. Standard library and third-party JARs: Not resolved; no edges are added for types outside the project source tree.
  • 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 .java sources are included in the graph.
  • Lambdas and method references: Resolution may be best-effort for complex functional call chains.
Terminal window
arxo analyze --path /path/to/java/project --config your-config.yaml

For JSON output (e.g. for scripting or CI):

Terminal window
arxo analyze --path /path/to/java/project --config your-config.yaml --json