@AspectJ

A Fine-Grained AspectJ Extension


Questions and issues to Walter Cazzola.

Limits of AspectJ: Pointcuts Granularity

Neglecting the fragility aspect of the pointcuts, AspectJ pointcuts are also unable to select all the possible join points. There are some computational patterns (also very simple) that cannot be captured by AspectJ [1]. The join point between two method calls or those bound to statements like if, while and expressions are the simplest examples of join points unselectable by using AspectJ.


In the above piece of code a couple of unselectable join points (marked by small red circles) are showed. The first is related to a boolean expression in a conditional statement; in this case the join point could be selected if the code were refactored and the expression were substituted by a call to a method encapsulating the expression. Unfortunately not always refactoring can be pursued or gives the desired results. For example, the second join point is attached to a specific call to the fib() method. This is already a method call and apparently not distinguishable, at least in AspectJ, from any other call to such a method. Also annotations do not help since they are, at least in the Java annotation model, attached to the method definition and not to an expression/statement.

The coarse grain of the join point model and its dependency on the program syntax permit to capture only those join points available in the application call graph [2] without considering its position or context. So it is really hard to choose among join points associated to the same program element (e.g., among all the calls to a given method) and to select those join points not explicit in the control flow graph (such as attached to an expression or inside a loop). This often hinders to get a neat separation of concerns.

  1. Tourwé, T., K. Gybels, and J. Brichau. On the Existence of the AOSD-Evolution Paradox. In Proceedings of SPLAT’03, Boston, MA, USA, Apr. 2003.
  2. Kiczales, G., E. Hilsdale, J. Hugunin, M. Kersten, J. Palm, and B. Griswold. An Overview of AspectJ. In Proceedings of ECOOP’01, LNCS 2072, pages 327–353, Budapest, Hungary, June 2001. Springer.

What is @AspectJ? And How does it work?

We developed @AspectJ to overcome such a limitation.

Our approach to solve this problem goes in the direction of providing a mechanism to explicitly mark the desired join points as in the annotation-based pointcuts of AspectJ 5+ (but with a finer granularity) rather than towards considering the context where the desired join point should be or the application semantics as in Alpha, Blueprint and Pitλ.

The basic idea is to exploit the fine-grained annotation model provided by the @Java_ programming language to allow the programmer to mark join points associated to single statements, block of statements and expressions to extend the join point model of AspectJ with a couple of primitive pointcuts to match such annotations.

Similarly to the changes introduced by @Java with respect to standard Java @AspectJ differs from standard AspectJ only for two new primitive pointcut: @block («annotation type») and @expr («annotation type»). These new pointcuts match a block and an expression annotation respectively.

The join points described in the previous example can be described and matched as follows.


The two new annotations @OnCond and @OnCall are used to mark the interesting join points. Through the new primitive pointcuts the occurrence of these annotations can be matched and advice can be woven on the corresponding join points.

the new primitive pointcuts can be combined with all the traditional AspectJ pointcuts and used in any kind of semantic action (before, after and around).

Getting started with @AspectJ

@AspectJ is currently distributed as a GNU/Linux RPM package file. It can be installed on every reasonably recent RPM-based distribution. (See at the end of the page for a list of the tested platform).

To successfully install and use @AspectJ you should have the following software properly installed and configured on your system:

Installing @AspectJ involves the following steps:

At this point you can compile your @AspectJ-enhanced source code with the ataspectjc compiler and run the program through the standard Java virtual machine.

@AspectJ has been tested on the following operating systems:

@AspectJ Staff

The @AspectJ project is led by Walter Cazzola.

References
  1. Marco Poggi. @AspectJ -- An Extension to the AspectJ Join Point Selection Mechanism to Support @Java Annotation Meta-Facility (In Italian). Master thesis, Università di Genova, Advisor Walter Cazzola. Genova, October 2009.

Walter Cazzola

Didactics

Publications

Funded Projects

Research Projects

Related Events








Valid XHTML 1.0 Transitional