Bug 121543 - cflow seems to cause StackOverFlowError
Summary: cflow seems to cause StackOverFlowError
Status: RESOLVED INVALID
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-20 05:58 EST by Mohan Radhakrishnan CLA
Modified: 2005-12-21 02:14 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mohan Radhakrishnan CLA 2005-12-20 05:58:38 EST
public class Foo{

	public static void method(){
	}

    public static void main(String[] args){
    	method();
     }
}

public aspect CFlowAspect {
    
    pointcut cflowMethod1(): cflow (execution(void Foo.method()));

    before(): cflowMethod1(){
        System.out.println("Before : " + thisJoinPoint);
    }
}

The code above seems to cause StackOverFlowError
at com.aspectj.test.CFlowAspect.ajc$before$com_aspectj_test_CFlowAspect$1$1b9bf60(CFlowAspect.aj)
	at com.aspectj.test.CFlowAspect.ajc$before$com_aspectj_test_CFlowAspect$1$1b9bf60(CFlowAspect.aj)
	at com.aspectj.test.CFlowAspect.ajc$before$com_aspectj_test_CFlowAspect$1$1b9bf60(CFlowAspect.aj)
..........
..........
	at com.aspectj.test.CFlowAspect.ajc$before$com_aspectj_test_CFlowAspect$1$1b9bf60(CFlowAspect.aj)
	at com.aspectj.test.CFlowAspect.ajc$before$com_aspectj_test_CFlowAspect$1$1b9bf60(CFlowAspect.aj)
Comment 1 Matt Chapman CLA 2005-12-20 06:02:43 EST
Passing to AspectJ compiler
Comment 2 Matt Chapman CLA 2005-12-20 06:08:48 EST
Mohan, I think your advice might be advising itself. That can cause a StackOverFlowError (like with infinite recursion). Try adding something like
"!within(CFlowAspect)" to your pointcut.
Comment 3 Andrew Clement CLA 2005-12-20 06:13:22 EST
yep - i agree with Matt - you need to extend your pointcut to prevent advising your advice.
Comment 4 Mohan Radhakrishnan CLA 2005-12-20 23:47:44 EST
Yes. Apology. This code works.

public aspect CFlowAspect {
    
    pointcut cflowMethod1(): cflow (execution(void Foo.method())) && !within(CFlowAspect);

    before(): cflowMethod1(){
        System.out.println("Before : " + thisJoinPoint);
    }
}
Comment 5 Adrian Colyer CLA 2005-12-21 02:14:57 EST
issued resolved as per previous comment by Mohan