Re: [abc-users] precedence rules in AspectJ

From: Thiago Bartolomei <>
Date: Tue Feb 21 2006 - 23:31:06 GMT

just comment on the example they give (I had to remove the args to test it).

  aspect A {
      before(): execution(void main(String[])) {}
      after(): execution(void main(String[])) {}
      before(): execution(void main(String[])) {}

Rules for advice in the same aspect:
I) If either are after advice, then the one that appears later in the aspect
has precedence over the one that appears earlier.
II) Otherwise, then the one that appears earlier in the aspect has
precedence over the one that appears later.

The precedence is circular because following the rules, you have to compare
each tuple:
1) the "after" must go before the 1st "before" (according to rule I)
2) the 2nd "before" must go before the "after" (according to rule I)
3) the 1st "before" must go before the 2nd "before" (according to rule II)

Since these rules cause a circularity, the compiler throws an error.

Hope it helps,

On 2/21/06, Klaus Havelund <> wrote:
> This question concerns advice precedence rules of AspectJ,
> specifically concerning
> precedence rules within a *single* aspect. I do not fully understand
> in what sitations
> the compiler yields inconsistency warnings (several advices apply to
> the same point).
> Can anyone explain these rules, or where I can read about it?
> Klaus
> An example of such a warning is:
> Pieces of advice from aspect
> DataInputStreamPolicy
> (, line 4) and aspect DataInputStreamPolicy
> (, line 31) and aspect DataInputStreamPolicy
> (, line 67) and aspect DataInputStreamPolicy
> (, line 4) are in precedence conflict, and
> all
> apply here
> int count = source.readInt();
Received on Tue Feb 21 23:31:10 2006

This archive was generated by hypermail 2.1.8 : Tue Feb 28 2006 - 23:50:04 GMT