Given these pointcuts taken from the following resource:
http://maverick-amey.blogspot.ru/2007/12/using-cflow-and-cflowbelow-in-pointcuts.html
pointcut methodCalls() :
call(public void Foo.*(..)) ;
pointcut methodCallFromWebTier() :
methodCalls() && cflow(call(* com.webtier.*+.*(..)));
The methodCallFromWebTier
pointcut is supposed to match all the calls made to any public method of the Foo
class with any arguments which returns void provided that (the && operator) the call is inside the control flow of any call made to a method of:
Now, if the pointcut would have been this instead:
pointcut methodCallFromWebTier() :
methodCalls() && cflow(call(* com.webtier.*.*(..)));
Therefore without the + subtype TypePattern operator, would the pointcut be the same? I mean, it still matches everything (any class, abstract class subclass, interface implementation) provided that this everything is inside the com.webtier package, so I don't really see the usage for the + sign here...
Am I wrong? Are there some edge cases that perhaps I don't see?
Is the plus sign really necessary in this example?
Thanks for the attention!
The plus would make a difference if you are working with types that subclass a type in the com.webtier
package but are not in the com.webtier
package. The plus would mean that those types would also be considered when computing cflow. If that doesn't happen in your application then the plus makes no difference.
It also makes a difference whether your Foo class is in the com.webtier
package. If it is then calls to it are always in the cflow of call(* com.webtier.*+.*(..))
. And if that were the situation I'd probably use cflowbelow
instead of cflow
.