Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] can we joinpoint on 'java.lang.Object'

Tarun,

Without further information, I would guess that *.new() is not what you
want. Why? Because it will end up advising the constructors of the objects
that AspectJ uses to do its work. This creates a problem. The aspect must be
constructed to advise any join points, but it cannot be constructed without
executing the advice. Try excluding the aspect in question using
!within(PostAspect).

Cheers,
Nick

On 8/29/03 8:17 PM, "Tarun Sharma" <t_sharma@xxxxxxxxxxxx> wrote:

> Hi Guys
> 
> Being new to aspectJ, I came across another problem and would highly
> appreciate any suggestions or comments on this issue.
> 
> Basically what I need to do is to put some "pointcut" on any_java_object,
> so "java.lang.Object" at "constructor execution" join point.So.. is this
> correct "execution(*.new())".?
> 
> I tried with a very simple aspect WHICH_DOES_NOT_SEEM to work for me. It
> was throwing NoClassDefFoundError, obviously I tried to decompile the
> class file where it was complaining and checked up the line number (there
> was this import org.aspectj.runtime.reflect.Factory ).I also checked the
> rt.jar I have in the classpath does indeed have this class file.?? To add
> to the mystery, if I dont use pointcut on "java.lang.object" and instead
> use on say one of my specialized class then everything is fine and there
> are no issue. So, I am not sure how far this error mmessage is correct as
> I seem to be stuck with options :
> 
> Any help will be highly greatful.
> 
> public aspect PostAspect {
> 
>   pointcut verify(java.lang.Object o) : execution(*.new()) && this(o);
> 
>   before(java.lang.Object o) : verify(o) {
>    System.out.println("[Aspect] before() : "+thisJoinPoint);
>   }
> 
>   after(java.lang.Object o) : verify(o){
>       System.out.println("[Aspect] after() : "+thisJoinPoint);
>   }
> }
> 
> Thanks...
> Tarun



Back to the top