Program Analysis

The CatchProcessor detects empty catch blocks.

The ReferenceProcessor detects circular references between packages.

This Factory example detects wrong uses of the factory pattern.

Program Transformation

The NotNull processor adds a not-null check for all method parameters.

The Mutation processor randomly mutates some parts of the abstract syntax tree for mutation testing.

Annotation Processing

The Stack example inserts code to ensure that the size of stack does not exceed the given bound. It uses a Spoon template.

The Nton 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.

The Database access example shows how to use annotation processing to add persistence into a POJO.

The Visitor example implements a visitor pattern by automatically introducing an accept method in a visited type hierarchy.

The Field Access 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.

Miscelanous

The Distributed Calculus example creates a fun new language for distributed computing using Java and Spoon.

Online source of all examples here.