Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 315651

Summary: wacky program causes unhelpful infinite loop
Product: [Tools] AspectJ Reporter: Andrew Clement <aclement>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 1.6.9   
Target Milestone: 1.6.9   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Andrew Clement CLA 2010-06-03 15:02:38 EDT
reported on the list by Eric Tanter:

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);
       }
}

this loops infinitely unless the commented out section is uncommented.
Comment 1 Andrew Clement CLA 2010-06-03 15:36:14 EDT
test and fix committed.  adjusted pointcut sorting order to make cflow ahead of if.  We were failing to consider the 'ConcreteCflowPointcut' class in PointcutEvaluationExpenseComparator.getScore()