JavaParser builds an AST for Java source from early language versions through current releases. Optional symbol resolution links code elements to declarations for analysis and refactoring.
Overview
JavaParser is a set of libraries that parse Java source into an abstract syntax tree and support programmatic analysis, transformation, and code generation. It targets a wide span of Java language versions from 1.0 through current releases.
The core module focuses on parsing and traversing syntax. JavaSymbolSolver, bundled from recent releases, resolves names to declarations such as parameters, fields, and types on top of the AST. A separate module can serialize the AST to JSON for tooling pipelines.
Typical uses include searching for code patterns, renaming or restructuring classes, and emitting boilerplate from templates. Artifacts publish to Maven Central for Gradle or Maven consumers, and the project documents quick-start snippets for parse, query, modify, and generate workflows.
The toolkit is dual-licensed under LGPL or Apache terms, and community releases track evolving Java syntax features.
Key features
- Java 1 through modern syntax parsing
- Programmatic AST traversal
- Optional JavaSymbolSolver module
- AST serialization to JSON
- Code pattern search and refactor
- On-the-fly source generation
- Maven Central distribution
- Dual LGPL or Apache license
Use cases
- Static analysis of Java codebases
- Automated refactors and codemods
- Generating Java boilerplate
- Lint-style policy enforcement
- Building Java-aware IDE features