Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Object Graph using aspectj

> seems to work accepts assignments with in methods. Any suggestions on how to
> do that?


there are no join points for assignments to local variables, if that is what you needed.  But related to this and your other point about this()/target() not working for you:

If you are using this()/target() to bind context, be aware that they will not match in a static context (this() wont match when the join point occurs within a static method for example, and there is no target() if a call is to a static method).  In these cases you need two sets of pointcuts, one set to handle the static case and one to handle the non-static case.

Andy.

2008/12/12 <mirza2m@xxxxxxxxx>
Thank you for your reply andrew.
Are you saying that this only works for assignments occurring outside
of methods? So, in initializers and field declarations?  Doesn't make
sense.  Can you be more specific?

You are right that did not make sense.

> seems to work accepts assignments with in methods. Any suggestions on how to
> do that?
should be
> seems to work accepts in case of assignments to local variables with in methods. I know this is because set pointcut does not trigger on local variable assignment but, is there another way to overcome this?

You need to bind these arguments.  So, you want to do something like this:

pointcut constructor(Object caller, Object created) : (call(*.new(..))
|| call(*.new())) &&
   !within(edu.testing.lib.*)  && target(created) && this(caller);

after (Object caller) returning (Object created) : constructor(caller,
created) {
 ...
}
I did try this but the pointcut stopped matching some join points i was interested in. I will try it again and report back.
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



Back to the top