View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3820351#3820351
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3820351 Absolutely. (I use the AspectJ terms because that's how it's easiest to explain). It's very similar to cflow. The cflow( methodCall ) is true if when you do the check, there is a call to methodCall somewhere in the stack trace. The cflowbelow( methodCall ) is true if when you do the check, there is a call to methodCall somewhere in the stack trace that *is not the top most element*. An example will help. public class Quicksort { public static void main( String[] args ) { new Quicksort().quicksort( ..... ); } public void quicksort( int[] numbers, int p, int r ) { if( p < r ) { int q = partition( numbers, p, r ); quicksort( A, p, q ); quicksort( A, q + 1, r ); } } // rest of quicksort here } public aspect QuicksortAspect { pointcut callsToQuicksort(): call( public void Quicksort.quicksort( int[], int, int ) ); pointcut nonRecursiveCalls(): callsToQuicksort() && !cflowbelow( callsToQuicksort() ); pointcut neverGetsCalled(): callsToQuicksort() && !cflow( callsToQuicksort() ); // this only gets called before the call to quicksort in main before(): nonRecursiveCalls() { System.out.println( "nonrecursive call to quicksort" ); } before(): neverGetsCalled() { System.out.println( "This never happens." ); } } The idea being that callsToQuicksort() picks out every time there is a call to Quicksort.quicksort(), and that !cflowbelow( callsToQuicksort() ) checks the current stack trace to see that excluding the top element, there are no other calls to quicksort having been made. If you included the top element, then you are looking for a call to quicksort which doesn't have a call to quicksort anywhere, which can't happen. I've never seen it used in any other way than to look for non-recursive calls to something, but I'm sure other uses exist. My apologies again for the AspectJ code, it seemed the best way :). Hope that all makes sense. Please ask away if it doesn't. Craig ------------------------------------------------------- The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. http://www.eclipsecon.org/osdn _______________________________________________ JBoss-Development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development
