Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Exposing the target object of a constructor call pointcut

Hi all,

 I was wondering whether we can expose the target object of a call pointcut.

 Consider the following simple class:

class C {

   public C () {}
   ...
}

along with the simple call pointcut and an after returning advice that uses such a pointcut:

pointcut callConst(C c) : call (public C.new()) && target(c);

after (C c) returning() : callConst(c){
 
    //advice code
}

The call pointcut callConst() will match any call to C's constructor but only when it does not include the target designator. Without the target designator we cannot expose the target object.

So, in the above example, the call is not matched! If we change the call to execution pointcut it matches normally (with context exposure )!

I want to know the main problem to have accessible the target object in a call pointcut that is used in a after returning advice. As I said, we can expose the object If we use a  after returning advice with execution pointcut. But, according to the AspectJ semantics, after returning call will occurs just after the method finishes its execution, so I ask again, Why we cannot use context exposure during a call? (at this time the, the constructor already instantiated the object!!). Is there a reason for that? or just a language limitation...

I just want to have interesting discussions about the AspectJ semantics!

cheers,
Henrique

--
...............................................................................................................................
Henrique Rebelo
http://www.cin.ufpe.br/~hemr
Informatics Center, UFPE, Brazil

Back to the top