[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] Bug #57993: before, after returning, then around gives circular dependency

Hi Ron -

I don't think this is a bug.  The docs say:

-----
If the two pieces of advice are defined in the same
aspect, then there are two cases:

(1) If either are after advice, then the one that appears
later in the aspect has precedence over the one
that appears earlier.
(2) Otherwise, then the one that appears earlier in
the aspect has precedence over the one that appears later.

These rules can lead to circularity, such as

aspect A {
      before(): execution(void main(String[] args)) {} // X
      after():  execution(void main(String[] args)) {} // Y
      before(): execution(void main(String[] args)) {} // Z
}
-----
Put another way:

(a) Y > X by (1)
(b) Z > Y by (1)
(c) X > Z by (2)
but
Z > X by (b) & (a)

That seem to  apply directly to your code:

aspect ThreeAdvices {
    before() : mainExec() { ... }
    after() returning : mainExec() { ... }
    void around() : mainExec() { ... }
}

As a general rule, put after advice last to avoid
advice circularity.  That's how you'd get the order
you were looking for in the bug.

(Also, I wouldn't hold up the release for any non-crashing
bug that has a workaround.)

Wes


Ron Bodkin wrote:

Folks,

Sorry about submitting bug #57993 at the last minute. I was trying to compile aTrack against the latest AspectJ in CVS HEAD and I remembered that I had worked around a compiler bug a while ago, so I finally went back and isolated it.

The bug happens when the same aspect advises the same join point with before, after returning, and around advice (in exactly that order). The compiler also gets the precedence wrong if you make the around advice go first...

I think this one is worth fixing in AspectJ 1.2

Ron

_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-dev