[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] thisJoinPoint.getThis() documentation

"this" at a call join point is the caller, not the callee,
because the caller is the currently-executing class/object.
See "State-based pointcuts" in the Programming Guide Semantics
appendix and also "join point shadow kinds" in Erik/Jim's paper:


Use "target(Callee)" if that's what you want.


P.S. - and remember: interception is a misconception;
join points, pointcuts, advice...

David.Suarez@xxxxxxxxxxx wrote:

Hello all,

I'm trying to understand the reason for this behavior though it is working
as documented....  I am running some code in a join point that occurs in an
object that must be instantiated.  The method that is getting intercepted
is not a static method but the caller is a static method in some cases but
not in others.  In the case where the caller is a static method,
thisJoinPoint.getThis() returns null (as documented).  It seems that the
getThis() should be able to return the object in use even if called by a
static method if the method itself is not static.  However this is not the
case as documented.  Any reason why since the object must be instantiated
within the static method and therefore this is a currently executing real
object?  Doesn't the byte code weaving just insert/pass a "this" reference
which would be valid in java?  Makes sense for a static method but not sure
why it's the case for a static method calling objects.  I am running in
threads from a J2EE app server presently, but does this mean that if I have
a plain java application which start from a "public static String(String[]
args)" I would never be able to use getThis() after the program starts
unless I spawn new threads?

I would appreciate any insight into why this is the case or if it really
needs to be the case (ie. can this be a feature request?).