Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] cflow(within(C)) vs (within(C) || cflowbelow(within(C))

Adrian,

I did get several NoClassDefFoundError during my experiment. One of
them used !cflowbelow(within(Trace*)). My *guess* (being new to AspectJ
and -- sort of -- Java) was that with cflowbelow(within(Trace*)),
TraceClass is still being traced by itself. So advices in TraceClass
would be executed for itself during its own initialization. Therefore
an error occured. Though I don't understand why it was a
"NoClassDefFoundError".

Chi-Hua

--- Adrian Powell <aspectj-users@xxxxxxxxxxxxxxxx> wrote:

>   Chi-Hua (and others),
> 
> Neat problems.  I've some simple ways to dodge the issue, but as I 
> played with your code, I kept coming up with more and more weird
> behavior.
> 
> >aspect, TraceClass, and was hoping that the aspect would print out
> all
> >the join points in SomeClass. 
> >
> The simple way to do this is to just use:
>     pointcut pc : within(SomeClass);
> 
> >To avoid infinite recursion, in
> >TraceClass I used "!cflow(within(Trace*))" as the pointcut. However,
> I
> >was not getting any output.
> >
> If you want to avoid tracing the trace, the best way to do this is to
> 
> just say "!within(TraceClass)".
> 
> 
> Now for the fun.  If I replace your pointcut with :
> 
>     pointcut pc() : !cflowbelow(within(TraceClass))
> 
> Then I get:
> 
> java.lang.NoClassDefFoundError
>     at test.SomeClass.<clinit>(SomeClass.java)
> Exception in thread "main"
> 
> But if I just add "&& !within(TraceClass)" or "&& !within(SomeClass)"
> 
> then oddly enough the problem goes away.  So what else is there?  
> Mysterious.
> 
> To make matters even more fun, I changed the pointcut to be:
> 
>     pointcut pc() : cflow(within(Trace*));
> 
> and now when I run it, not only do I get the same output as above,
> but I 
> get a dialog box appearing with the title "Java Virtual Machine 
> Launcher" saying "Could not find the main class.  Program will exit."
> 
> Wowsers.  Anyone know what is going on?
> 
> ------
> package test;
> public class SomeClass {
>     public static void main(String[] args) {
>     }
> }
> -----
> package test;
> public aspect TraceClass {
>     pointcut pc() : cflow(within(Trace*));  // JVM dialog box error
>     // pointcut pc() : !cflowbelow(within(TraceClass));  // 
> ExceptionInInitializerError
> 
>     before () : pc() {
>         System.out.println("-> " +
>                 thisJoinPointStaticPart.toString());
>     }
> }
> -------
> 
> -adrian.
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 



Back to the top