Spoon
What it is
Spoon is a free, open-source Java library for analyzing and changing source code through an abstract syntax tree (AST). It parses Java files into that model and provides APIs for inspection, transformation, rewriting, and transpilation. Its processors support source-level static analysis by examining AST elements of a selected type. Developers can express architecture rules as AST checks and run them as JUnit tests in continuous integration. Transformation uses include instrumentation and refactoring, with helpers for local and generic variables and removing deprecated methods. Spoon can also provide an alternative to Java reflection, with CtClass objects enabling shared analysis of binary and source code. The project documents support for modern Java versions up to Java 25, but the required runtime depends on the Spoon release: 11.x needs JDK 17 or later, 10.x needs JDK 11 or later, and 9.x needs Java 8. It can be used from Java, the command line, Maven, or Gradle. Command-line users manage the classpath manually and should specify analyzed-source dependencies with --source-classpath. Spoon is an official Inria project and an OW2 consortium member.
For and against
For
- Supports analysis and transformation through an AST.
- Architecture rules can run as JUnit tests.
- Works through Java, command line, Maven, or Gradle.
- Free under CeCILL-C and MIT licenses.
Against
- Runtime JDK requirements vary by Spoon release.
- Command-line users manage the classpath manually.
- Semantic patching is described as a prototype subset.
The verdict
Spoon provides a Java-focused toolkit for source-level analysis and transformation, including CI-friendly architecture checks. Check the required JDK for the release in use, and account for manual classpath setup from the command line.
Who it suits
Spoon suits Java developers building source analysis, architectural checks, instrumentation, or refactoring tools. It is also relevant to teams that run AST-based checks in continuous integration.
Plans and prices
Free and Open Source
No paid plans or usage limits stated
Read 5 Oct 2026 · spoon.gforge.inria.fr
On the record
- Analysis
- Spoon supports source-level static code analysis using processors that inspect AST elements of a selected type.spoon.gforge.inria.fr · read 5 Oct 2026
- Architecture checks
- The documentation describes expressing architectural rules as AST analysis and running them as JUnit tests in continuous integration.spoon.gforge.inria.fr · read 5 Oct 2026
- AST model
- It parses Java source files into an abstract syntax tree with analysis and transformation APIs.spoon.gforge.inria.fr · read 5 Oct 2026
- Code transformation
- Spoon can transform source code, including for instrumentation and refactoring.spoon.gforge.inria.fr · read 5 Oct 2026
- Command-line limitation
- When using Spoon from the command line, users handle the classpath manually and should specify dependencies of analyzed source files with --source-classpath.spoon.gforge.inria.fr · read 5 Oct 2026
- Community
- The project welcomes external contributions through pull requests.spoon.gforge.inria.fr · read 5 Oct 2026
- Compatibility limit
- Although it can consume source code for older Java versions, Spoon needs the specified JDK version to run.spoon.gforge.inria.fr · read 5 Oct 2026
- Install options
- The documentation describes using Spoon from Java, the command line, Maven, or Gradle, and downloading its dependency jar from Maven Central for command-line use.spoon.gforge.inria.fr · read 5 Oct 2026
- Integrations
- The site documents Maven and Gradle usage, along with command-line execution using a JAR from Maven Central.spoon.gforge.inria.fr · read 5 Oct 2026
- Java runtime requirements
- Spoon 11.x requires JDK 17 or later, Spoon 10.x requires JDK 11 or later, and Spoon 9.x requires Java 8.spoon.gforge.inria.fr · read 5 Oct 2026
- Java support
- The site says Spoon supports modern Java versions up to Java 25.spoon.gforge.inria.fr · read 5 Oct 2026
- License
- Spoon is free and open source under the CeCILL-C and MIT licenses.spoon.gforge.inria.fr · read 5 Oct 2026
- Parallel processing
- Spoon provides an AbstractParallelProcessor API for running processors in parallel, with the documentation advising against using more parallel processors than available cores.spoon.gforge.inria.fr · read 5 Oct 2026
- Project affiliation
- The site identifies Spoon as an official Inria open-source project and a member of the OW2 open-source consortium.spoon.gforge.inria.fr · read 5 Oct 2026
- Purpose
- Spoon is an open-source library for analyzing, rewriting, transforming, and transpiling Java source code.spoon.gforge.inria.fr · read 5 Oct 2026
- Refactoring
- The documentation describes local-variable and generic-variable refactoring helpers, as well as a helper for removing deprecated methods.spoon.gforge.inria.fr · read 5 Oct 2026
- Reflection
- Spoon can act as an alternative to Java reflection and allows shared analysis of binary and source code through CtClass objects.spoon.gforge.inria.fr · read 5 Oct 2026
- Runtime requirement
- Spoon 11.x requires JDK 17 or later, 10.x requires JDK 11 or later, and 9.x requires Java 8 to run.spoon.gforge.inria.fr · read 5 Oct 2026