While aspects define types that crosscut, 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:
after
returning
advice.
this
pointcut. The constructor execution
join point for a constructor that calls a super constructor also
includes any non-static initializers of enclosing class. No
value is returned from a constructor execution join point, so its
return type is considered to be void.
this()
and
super()
constructor calls. No value is
returned from an object pre-initialization join point, so its
return type is considered to be void.
this
pointcut. No value is returned from a
constructor execution join point, so its return type is
considered to be void.
Each join point potentially has three pieces of state associated
with it: the currently executing object, the target object, and
an object array of arguments. These are exposed by the three
state-exposing pointcuts, this
,
target
, and args
,
respectively.
Informally, the currently executing object is the object that a
this
expression would pick out at the join
point. The target object is where control or attention is
transferred to by the join point. The arguments are those
values passed for that transfer of control or attention.
Join Point | Current Object | Target Object | Arguments |
---|---|---|---|
Method Call | executing object* | target object** | method arguments |
Method Execution | executing object* | executing object* | method arguments |
Constructor Call | executing object* | None | constructor arguments |
Constructor Execution | executing object | executing object | constructor arguments |
Static initializer execution | None | None | None |
Object pre-initialization | None | None | constructor arguments |
Object initialization | executing object | executing object | constructor arguments |
Field reference | executing object* | target object** | None |
Field assignment | executing object* | target object** | assigned value |
Handler execution | executing object* | executing object* | caught exception |
Advice execution | executing aspect | executing aspect | advice arguments |
* There is no executing object in static contexts such as static method bodies or static initializers.
** There is no target object for join points associated with static methods or fields.