AspectJ, Aspect Oriented Programming in Java

Aspect J is a Java extension that implements aspect-oriented programming, a technique that modularize crosscutting concerns.

Using AspectJ can reduce dramatically the size of a Java Program without a lost in performance, and simplify the design in the same degree.
It improves modularity and reusability of code.
And it is especially useful for debugging large projects.

AspectJ was made available in 2001 and AOP is more than fifteen years old and developed at Palo Alto Research Center since 1994.
Here the unit is not the class, but a concern, that spans multiple classes. Concern may be for example properties, area of interest, of a system and AOP describes their relationship, and compose them together into a program. Aspects encapsulates behavior that concern multiple classes.
Aspects of a system can be inserted, changed, removed at compile time.

Features of AspectJ

Sample code

This aspect concerns the execution of any method in the Eclipse program.
An advice executes some code before each method is called, and an other one executes some code after the call.

public aspect xxxx
{
      pointcut anyMethod() : execution (* org.eclipse.. *(..));
      before(): anyMethod()
      {
            ... some code...
      }
      after() : anyMethod()
      {
           ... some code...
       } 
}

Tools and documentation

Programming languages AspectJ - Basic - C - CIL - C++ - C++11 - C# - Dart - Eiffel - Go - Java - JavaScript - JavaFX Script - Pascal - PHP - Python - QML - Rexx - Ruby - Scala - Scriptol - Tcl - HTML - XML - XAML - XUL - SQL