[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] If pointcut and side effects

> Why was this decision made? For better/faster implementation? From a
> usability point of view, one would certainly like to have control over
> the evaluation order (especially since AspectJ is an augmentation of
> Java where boolean expressions have a defined order).

Using the same "lazy/jumpingcode" evaluation technique for pointcuts as
you know it from Boolean expressions would not make much sense, e.g. for
the following reason. Imagine the following three pointcuts:

pointcut p1(int i): args(i) && if(i>2) && call(* Foo.*(int));
pointcut p1(int i): if(i>2) && args(i) && call(* Foo.*(int));
pointcut p2(int i): call(* Foo.*(int)) && args(i) && if(i>2);

I think we both agree that those two pointcuts should always match the
same joinpoints. If you now evaluated p1 as you suggest, that means that
first at *any* method with an int argument we have to bind this
argument, check if it's >2 and then last but not least we check if this
method is actually in class Foo at all. Would make no sense, would it?
Just imagine the runtime overhead. Pointcut p2 would be even worse: You
would access i before having it bound! Consequently, any sensible
compiler will generate the residues in the order depicted by pointcut
p3. This would lead to dynamic residues only be inserted in inside the
class Foo and with the appropriate signature. Also, values being
accessed by if pointcuts will be bound, since if pointcuts are moved to
the end.

> Are there any simple rules that can be stated about evaluation order
> given the current (eclipse) implementation of AspectJ? (I know I
> shouldn't rely on them but I'm curious)

No, and there should not be any rules. It's an *if* pointcut, meant to
evaluate a sideeffect-free Boolean expression and for nothing else. I am
really wondering what you are trying to achieve by this technique. I
never found a need for such a thing.


Eric Bodden
Sable Research Group, McGill University
Montreal, Canada