Annotation Processing and Templates
Stack
This example is a typical stack annotated with a Bound annotation. It inserts a block of templated code into the stack to ensure that its size does not exceed the given bound.
Nton
This example introduces a Nton design pattern (extension of singleton but for N instances) into a target class. It inserts static fields, methods, and initializer code into constructors.
Database Access
This example shows how use annotation processing to add persistence into a POJO.
Visitor
This example implements a visitor pattern in an automatic way by using a processor that introduces an accept method in a visited type hierarchy.
Field Access
This example implements a refactoring that introduces setters and getters for the fields annotated with the Access annotation and that replaces all the direct accesses to these fields by calls to its new getters and setters.
Delegate
This example creates a delegate class for an annoted interface.
Program Analysis, Statistics, and Programming Mistakes Detection
Analysis
This example implements some very simple analysis of programs. The CatchProcessor detects empty catch blocks. the ReferenceProcessor detect circular references between packages.
Factory
This example detects wrong uses of the factory pattern.
Miscelanous
Distributed Calculus
This example creates a fun distributed computing programing model, using Java and Spoon to create a new language.
Class Loader
This example shows how to use spoon to made load-time transformation.

