Appendix B. Language Semantics

Table of Contents

Join Points
Pointcuts
Pointcut naming
Context exposure
Primitive pointcuts
Signatures
Type patterns
Pointcuts and Join Points
Advice
Advice modifiers
Advice and checked exceptions
Advice precedence
Reflective access to the join point
Static crosscutting
Member introduction
Access modifiers
Conflicts
Extension and Implementation
Interfaces with members
Warnings and Errors
Softened exceptions
Statically determinable pointcuts
Aspects
Aspect Extension
Aspect instantiation
Aspect privilege
Aspect domination

AspectJ extends Java by overlaying a concept of join points onto the existing Java semantics and by adding adds four kinds of program elements to Java:

Join points are well-defined points in the execution of a program. These include method and constructor calls, field accesses and others described below.

A pointcut picks out join points, and exposes some of the values in the execution context of those join points. There are several primitive pointcut designators, new named pointcuts can be defined by the pointcut declaration.

Advice is code that executes at each join point in a pointcut. Advice has access to the values exposed by the pointcut. Advice is defined by before, after, and around declarations.

Introduction and declaration form AspectJ's static crosscutting features, that is, is code that may change the type structure of a program, by adding to or extending interfaces and classes with new fields, constructors, or methods. Introductions are defined through an extension of usual method, field, and constructor declarations, and other declarations are made with a new declare keyword.

An aspect is a crosscutting type, that encapsulates pointcuts, advice, and static crosscutting features. By type, we mean Java's notion: a modular unit of code, with a well-defined interface, about which it is possible to do reasoning at compile time. Aspects are defined by the aspect declaration.

Join Points

While aspects do define crosscutting types, the AspectJ system does not allow completely arbitrary crosscutting. Rather, aspects define types that cut across principled points in a program's execution. These principled points are called join points.

A join point is a well-defined point in the execution of a program. The join points defined by AspectJ are:

Method call

When a method is called, not including super calls of non-static methods.

Method execution

When the body of code for an actual method executes.

Constructor call

When an object is built and a constructor is called, not including this or super constructor calls. The object being constructed is returned at a constructor call join point, so it may be accessed with after returning advice.

Initializer execution

When the non-static initializers of a class run.

Constructor execution

When the body of code for an actual constructor executes, after its this or super constructor call. The object being constructed is the currently executing object, and so may be accessed with the this pointcut. No value is returned from constructor execution join points.

Static initializer execution

When the static initializer for a class executes.

Object pre-initialization

Before the object initialization code for a particular class runs. This encompasses the time between the start of its first called constructor and the start of its parent's constructor. Thus, the execution of these join points encompass the join points from the code found in this() and super() constructor calls.

Object initialization

When the object initialization code for a particular class runs. This encompasses the time between the return of its parent's constructor and the return of its first called constructor. It includes all the dynamic initializers and constructors used to create the object. The object being constructed is the currently executing object, and so may be accessed with the this pointcut. No value is returned from constructor execution join points.

Field reference

When a non-final field is referenced.

Field assignment

When a field is assigned to.

Handler execution

When an exception handler executes.