[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-dev] Set-Pointcut does not match
|
On Wed, 11 Aug 2004, Eric Bodden wrote:
> before(): set(* state) {
> if(state==2)
> System.out.println("Matched."+this);
> }
[...]
> I am never seeing the output "Matched." - though the other advices
> function and the state is set to 2 at some point. The whole advice is
> never executed. But as you can easily see any of the others *does*
> set the field "state".
I haven't been through the entire logic to see what happens in what order,
but this is before advice, so the test if(state==2) will see the value of
state *before* it is set. So you need both for state to be set to 2 and
then set to something else afterwards for the println to run.
If you really want this to be before advice, something like this should
work:
before(int x): set(* state) && args(x) {
if(x==2)
System.out.println("Matched."+this);
}
The if could be made a pointcut if you wanted, too.
Ganesh