[aosd-discuss] Naive question About Cflow Point cut
Michael Haupt
haupt at informatik.tu-darmstadt.de
Tue Feb 8 03:52:17 EST 2005
Hi Eric,
Eric Bodden wrote:
> class A {
> int field;
>
> void foo() {
> this.field = someComplicatedCalculation(someEvaluation());
> }
> ...
> }
>
> As you will know, the call above *can* be matched by a set-pointcut
> on A.field. before(set(* A.field)) will execute before the set event
> (and before the call to someComplicatedCalculation(...)),
the invocation of the complex calculation is an entirely different join
point and has nothing to do with the set join point that is matched by
the set() PCD. After all, the actual *set* join point occurs *after* the
complex calculation has returned.
> [...] cflow(set(* A.field))
> however, will match all the joinpoints in between, which in this case
> will be everything from the inner call to someEvaluation() untill the
> return of someComplicatedCalculation(...)).
If we assume that someComplicatedCalculation() is a method declared in
A, a pointcut like this one:
call(* A.*(..)) && cflow(set(int A.field))
will match nothing. One might ask whether a combination like
cflow(set(...)) makes sense at all.
There is some interesting behaviour if you attach some advice to the set
join point that prints to System.out, and use a combination of this with
a pointcut like the above. You will observe that cflow(set(...)) matches
those join points that are introduced by advice attached to the set join
point.
Example:
-----
before(): set(int A.field) {
System.out.println("set");
}
before(): call(* *(..)) && cflow(set(int A.field)) {
System.out.println("cflow match");
}
-----
This will eventually end up in a stack overflow because all calls to
System.out.println() in the first advice will be matched by the second
pointcut.
Best regards,
Michael Haupt
--
Dipl.-Ing. Michael Haupt haupt at informatik.tu-darmstadt.de
Software Technology Group Phone: ++49 (0) 6151-16-5306
Darmstadt University of Technology Fax: ++49 (0) 6151-16-5410
Hochschulstr. 10, 64289 Darmstadt, Germany
http://www.st.informatik.tu-darmstadt.de/
More information about the discuss
mailing list