You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PR560.java 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import org.aspectj.testing.Tester;
  2. /**
  3. * @testcase PR#560 compile fails for aspect derived from percflow base aspect unless pointcut excludes base aspect and subaspects
  4. * - works with issingleton perthis and pertarget
  5. * - works when advice is in the same class/aspect
  6. */
  7. public class PR560 { // XXX broken?
  8. public static void main( String args[] ) {
  9. Tester.expectEvent("Target.run()");
  10. Tester.expectEvent("same aspect");
  11. Tester.expectEvent("derived aspect");
  12. new Target().run();
  13. Tester.checkAllEventsIgnoreDups();
  14. }
  15. }
  16. class Target {
  17. public void run(){
  18. Tester.event("Target.run()");
  19. }
  20. }
  21. abstract aspect Base percflow(callcflow()) {
  22. pointcut callcflow()
  23. : cflow(call(public void Target.run()))
  24. && !within(Base+)
  25. ;
  26. before() : within(Target) {
  27. Tester.event("same aspect");
  28. }
  29. }
  30. aspect Derived extends Base {
  31. before() : within(Target) {
  32. Tester.event("derived aspect");
  33. }
  34. }
  35. /*
  36. -- passing variants
  37. -
  38. : cflow(call(public void Target.run()))
  39. && !within(Base+)
  40. -- failing variants
  41. -
  42. : cflow(call(public void Target.run()) && !within(Derived))
  43. (cflowbelow selects Derived.*)
  44. -
  45. : cflow(call(public void Target.run()))
  46. && !cflow(within(Derived))
  47. (cflowbelow selects Base.*)
  48. -
  49. : cflow(call(public void Target.run()) && !within(Base+))
  50. (cflowbelow selects Base.*)
  51. -
  52. : cflow(call(public void Target.run()))
  53. && !this(Base+)
  54. (some join points in Base/Derived do not have Base/Derived as this)
  55. -
  56. : cflow(call(public void Target.run()))
  57. && !target(Base+)
  58. (some join points in Base/Derived do not have Base/Derived as target)
  59. */