Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: PerTarget - Bug or missunderstanding? was: [aspectj-dev] Set-Pointcut does not match

Hello,

I think that you need to modify your code from this:

	aspect PushUntilPop pertarget(pushPop()){

		int state;

		pointcut pushPop() : pu(Object) || po();
		pointcut pu(Object o): call(* IStack.push(..)) && args(o);
		pointcut po(): call(* IStack.pop());

	[...]
	
		after(): set(* state) {
			System.out.println("Matched."+this);
		}

to this:

	aspect PushUntilPop pertarget(pushPopSet()){

		int state;

		pointcut pushPopSet() : pu(Object) || po() || s();
		pointcut pu(Object o): call(* IStack.push(..)) && args(o);
		pointcut po(): call(* IStack.pop());
		pointcut s(): set(* state);

	[...]
	
		after(): s() {
			System.out.println("Matched."+this);
		}

See the explanation of Per-object aspects in the programming guide (page 86):

"Similarly, if an aspect A is defined pertarget(Pointcut),
then one object of type A is created for every object
that is the target of the join points picket out by Pointcut.
The advice defined in A may then run at any join point
where the target object has been associated with an instance of A."

Your original pertarget-argument pointcut (pushPop()) does not pick the field settings.

This makes me think if a warning could be emitted by the compiler in cases where the aspect contains advices whose pointcuts are not picked up by the pertarget argument expression.

Regards,
Gyula

> 
> Don't bother about the first advice: It *will* be called at some
> point. Thus, state will be set to two (if I set it from the outside,
> it makes no difference).
> The weird thing now is: If I use the pertarget above, the second
> pointcut does never match. If I omit it, it matches as expected on
> the set event in the first advice.
> So what is going wrong here?
> 
> Eric
> 
> - -- 
> Eric Bodden
> Chair I2 for Programming Languages and Program Analysis
> RWTH Aachen University
> 
> -----BEGIN PGP SIGNATURE-----
> Version: PGP 8.0.3
> 
> iQA/AwUBQRsvfMwiFCm7RlWCEQLjewCfeUdvO4fcAO6ixoI8U7RUm0yGVi8An3kK
> 4q8Hl7Zsxvq2otHjIMmnR14A
> =15gF
> -----END PGP SIGNATURE-----
> 
> 
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-dev
> 


Back to the top