Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Abstract aspect and !cflow(within) results in ExceptionInInitializerError


Benjamin,

Try this instead:

package test1;

abstract privileged aspect Aspect
{
        before(Test self) : execution(* Test.sayHello())
                && this(self) && !cflow(within(Aspect) && adviceexecution())
        {
                System.out.println("before:sayHello");
                self.sayHello();
        }
}

You are experiencing a variation on the problem of advising yourself. Sometimes you get NoAspectBoundExeption. Your within(Aspect) pointcut matches more join points that you need including static initialization.

Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/



Benjamin Mesing <benjamin.mesing@xxxxxxxxxxxxxxxxxxxxxxxxx>
Sent by: aspectj-users-bounces@xxxxxxxxxxx

28/11/2006 12:23

Please respond to
aspectj-users@xxxxxxxxxxx

To
aspectj-users@xxxxxxxxxxx
cc
Subject
[aspectj-users] Abstract aspect and !cflow(within) results in        ExceptionInInitializerError





Hello,

with the program given below, I get the exception:

Exception in thread "main" java.lang.ExceptionInInitializerError
       at test1.Test.sayHello(Test.java:7)
       at test1.Test.main(Test.java:13)
Caused by: java.lang.NullPointerException
       at test1.Aspect.<clinit>(Aspect.aj:1)
       ... 2 more

Making "Aspect" concrete and removing "ExtendedAspect" makes everything work
fine.
This appears to be a bug in ajc. Do you agree?

Thanks,

Benjamin


---test1/Test.java---
package test1;

public class Test
{
       public void sayHello()
       {
               System.out.println("hello World");
       }
       
       public static void main(String[] args)
       {
               Test hw = new Test();
               hw.sayHello();
       }
}

---test1/Aspect.aj---
package test1;

abstract privileged aspect Aspect
{
       before(Test self) : execution(* Test.sayHello())
               && this(self) && !cflow(within(Aspect))
       {
               System.out.println("before:sayHello");
               self.sayHello();
       }
}

---test1/ExtendedAspect.aj---
package test1;

public aspect ExtendedAspect extends Aspect
{
}

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


Back to the top