Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] cflow joinpoint confusion

Hi,
 
I have the following code structure:
 
 public class Test {
     public static int callx() {
        return Test2.returnInt();
     }
     
     public static int callAgain() {
        returnTest2.returnInt();
      }
}
 
 
public class Test2 {
     public static int returnInt() {
         return 2;
     }
}
I would like to capture the call to Test2.returnInt() from the function Test.callx() For that I wrote the following pointcuts and advice:
 

pointcut exec() : withincode(public static int callx());
pointcut callx() : call(public static int returnInt());
   
    int around() : cflow(exec()) && callx() {
        System.out.println("Passed around it");
        return -1;
    }

Since I am doing cflow(exec()) && callx() I would assume that only one call to "returnInt()" i.e. the one inside function "callx()" would be captured. But AspectJ captures both the calls to "returnInt( ) " i.e the one in "callx( )" and in "callAgain( )".

Can someone please tell me what am I doing wrong and how can I capture only one pointcut i.e. the one inside of callx( ).

Thanks a lot in advance for all your help.

Irum Godil.

 


Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.

Back to the top