Skip to main content

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

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[quote Irum Godil::on 1/30/2005 11:41 PM]
| 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.

A simple solution would be to use withincode(public static int callx()) && call(public static int
returnInt()).


- --
:pope
[the_mindstorm]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)

iD8DBQFB/VexTTDTje0R2dgRAjsQAJ40luTTJvlji50x4G0gWV2cAjlz+wCfZk9f
Rs4TrBFFNNG/plz3BmXiYmA=
=sI+4
-----END PGP SIGNATURE-----


Back to the top