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, [EMAIL PROTECTED]
http://w3.hursley.ibm.com/~websterm/
Benjamin Mesing <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]
28/11/2006 12:23
Please respond to
[email protected]
To
[email protected]
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
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users