Hi,
From the semantics of AspectJ, it is given that cflow(pc()) *always* matches
whenever pc() matches.
While exploring some dark corners, we stumbled across a case where this is
however _not_ the case.
It has a strong feel of being a bug, but maybe not, so please let us know.
The code below shows that the program with the scope() pointcut defined as:
if(condition()) && !cflow(execution(* *.condition()));
enters an infinite loop, while adding the condition
&& !(execution(* *.condition()))
does not loop anymore (ie. works fine).
So this is a case where
!cflow(pc()) && !pc() is _not_ equivalent to !cflow(pc())
(and according to the semantics, it should be:
!cflow(pc()) && !pc()
=
!(cflow(pc()) || pc())
where the || pc() part is clearly redundant
Some additional notes:
- this does not have anything to do, it seems, with the fact that lexical join
points in if pcds are hidden (we are talking about execution pcds in the code,
not calls)
- moving the condition() method outside of the aspect does not change what we
observe.
Can you confirm if this is a bug, or are we missing something??
Thanks,
-- Éric
package test;
public aspect Profiling {
pointcut profile(): execution(* *.*(..)) ;
private pointcut scope() :
if(condition())
//&& !(execution(* *.condition())) <- uncomment and
infinite loop disappears
&& !cflow(execution(* *.condition()));
public static boolean condition(){
return (Math.random()<2); //always true
}
before(): profile() && scope() {
System.out.println("Entering method
"+thisJoinPointStaticPart.getSignature());
}
}
package test;
public class Main {
private static int plus(int first, int second){
return first + second;
}
public static void main(String[] args) {
int num = plus(42,13);
System.out.println(num);
}
}
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users