blob: 5444b437a88d829d7fca262d4d3bd2f3a98c6219 [file] [log] [blame]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Join Points</title><link rel="stylesheet" href="aspectj-docs.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.44"><link rel="home" href="index.html" title="The AspectJTM Programming Guide"><link rel="up" href="semantics.html" title="Appendix B. Language Semantics"><link rel="previous" href="semantics.html" title="Appendix B. Language Semantics"><link rel="next" href="semantics-pointcuts.html" title="Pointcuts"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Join Points</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="semantics.html">Prev</a>&nbsp;</td><th width="60%" align="center">Appendix B. Language Semantics</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="semantics-pointcuts.html">Next</a></td></tr></table><hr></div><div class="sect1"><a name="semantics-joinPoints"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="semantics-joinPoints"></a>Join Points</h2></div></div><p>
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.
</p><p>
A join point is a well-defined point in the execution of a
program. The join points defined by AspectJ are:
</p><div class="variablelist"><dl><dt><a name="d0e4541"></a><span class="term">Method call</span></dt><dd>
When a method is called, not including super calls of
non-static methods.
</dd><dt><a name="d0e4546"></a><span class="term">Method execution</span></dt><dd>
When the body of code for an actual method executes.
</dd><dt><a name="d0e4551"></a><span class="term">Constructor call</span></dt><dd>
When an object is built and that object's initial constructor is
called (i.e., not for "super" or "this" constructor calls). The
object being constructed is returned at a constructor call join
point, so its return type is considered to be the type of the
object, and the object itself may be accessed with <tt>after
returning</tt> advice.
</dd><dt><a name="d0e4559"></a><span class="term">Constructor execution</span></dt><dd>
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 <tt>this</tt> 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.
</dd><dt><a name="d0e4567"></a><span class="term">Static initializer execution</span></dt><dd>
When the static initializer for a class executes. No value is
returned from a static initializer execution join point, so its
return type is considered to be void.
</dd><dt><a name="d0e4572"></a><span class="term">Object pre-initialization</span></dt><dd>
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 of the
evaluation of the arguments of <tt>this()</tt> and
<tt>super()</tt> constructor calls. No value is
returned from an object pre-initialization join point, so its
return type is considered to be void.
</dd><dt><a name="d0e4583"></a><span class="term">Object initialization</span></dt><dd>
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
<tt>this</tt> pointcut. No value is returned from a
constructor execution join point, so its return type is
considered to be void.
</dd><dt><a name="d0e4591"></a><span class="term">Field reference</span></dt><dd>
When a non-constant field is referenced. [Note that references
to constant fields (static final fields bound to a constant
string object or primitive value) are not join points, since Java
requires them to be inlined.]
</dd><dt><a name="d0e4596"></a><span class="term">Field set</span></dt><dd>
When a field is assigned to.
Field set join points are considered to have one argument,
the value the field is being set to.
No value is returned from a field set join point, so
its return type is considered to be void.
[Note that the initializations of constant fields (static
final fields where the initializer is a constant string object or
primitive value) are not join points, since Java requires their
references to be inlined.]
</dd><dt><a name="d0e4601"></a><span class="term">Handler execution</span></dt><dd>
When an exception handler executes.
Handler execution join points are considered to have one argument,
the exception being handled.
No value is returned from a field set join point, so
its return type is considered to be void.
</dd><dt><a name="d0e4606"></a><span class="term">Advice execution</span></dt><dd>
When the body of code for a piece of advice executes.
</dd></dl></div><p>
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, <tt>this</tt>,
<tt>target</tt>, and <tt>args</tt>,
respectively.
</p><p>
Informally, the currently executing object is the object that a
<tt>this</tt> 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.
</p><div class="informaltable" id="d0e4627"><a name="d0e4627"></a><table border="1"><colgroup><col><col><col><col></colgroup><thead valign="top"><tr><th><span class="bold"><b>Join Point</b></span></th><th><span class="bold"><b>Current Object</b></span></th><th><span class="bold"><b>Target Object</b></span></th><th><span class="bold"><b>Arguments</b></span></th></tr></thead><tbody><tr><td>Method Call</td><td>executing object*</td><td>target object**</td><td>method arguments</td></tr><tr><td>Method Execution</td><td>executing object*</td><td>executing object*</td><td>method arguments</td></tr><tr><td>Constructor Call</td><td>executing object*</td><td>None</td><td>constructor arguments</td></tr><tr><td>Constructor Execution</td><td>executing object</td><td>executing object</td><td>constructor arguments</td></tr><tr><td>Static initializer execution</td><td>None</td><td>None</td><td>None</td></tr><tr><td>Object pre-initialization</td><td>None</td><td>None</td><td>constructor arguments</td></tr><tr><td>Object initialization</td><td>executing object</td><td>executing object</td><td>constructor arguments</td></tr><tr><td>Field reference</td><td>executing object*</td><td>target object**</td><td>None</td></tr><tr><td>Field assignment</td><td>executing object*</td><td>target object**</td><td>assigned value</td></tr><tr><td>Handler execution</td><td>executing object*</td><td>executing object*</td><td>caught exception</td></tr><tr><td>Advice execution</td><td>executing aspect</td><td>executing aspect</td><td>advice arguments</td></tr></tbody></table></div><p>* There is no executing object in static contexts such as
static method bodies or static initializers.
</p><p>** There is no target object for join points associated
with static methods or fields.
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="semantics.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="semantics-pointcuts.html">Next</a></td></tr><tr><td width="40%" align="left">Appendix B. Language Semantics&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="semantics.html">Up</a></td><td width="40%" align="right">&nbsp;Pointcuts</td></tr></table></div></body></html>