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.

GeneratingDuplicateNamedAdviceMethodsInAbstractAspectsWithExtendedAspect.java 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import org.aspectj.testing.Tester;
  2. import org.aspectj.testing.Tester;
  3. public class
  4. GeneratingDuplicateNamedAdviceMethodsInAbstractAspectsWithExtendedAspect
  5. {
  6. public static void main(String[] args) {
  7. new GeneratingDuplicateNamedAdviceMethodsInAbstractAspectsWithExtendedAspect().realMain(args);
  8. }
  9. public void realMain(String[] args) {
  10. new C().c();
  11. Tester.checkAllEvents();
  12. }
  13. static {
  14. Tester.expectEvent("c");
  15. String[] strs = {"before","after","around"};
  16. for (int i = 0; i < strs.length; i++) {
  17. int[] is = new int[] {1,2};
  18. for (int j = 0; j < is.length; j++) {
  19. Tester.expectEvent(strs[i]+is[j]);
  20. }
  21. }
  22. }
  23. }
  24. class C {
  25. public void c() { Tester.event("c"); }
  26. }
  27. abstract aspect A {
  28. pointcut c(): call(void C.c());
  29. protected static void a(String str, Object o) {
  30. Class c = o.getClass();
  31. Tester.event(str);
  32. Tester.check(!A.class.equals(c), "A is abstract!");
  33. Tester.check(Inner.class.equals(c), "Inner must equal "+c);
  34. }
  35. after(): c() { a("after1", this); }
  36. after(): c() { a("after2", this); }
  37. before(): c() { a("before1", this); }
  38. before(): c() { a("before2", this); }
  39. void around(): c() { a("around1", this); proceed(); }
  40. void around(): c() { a("around2", this); proceed(); }
  41. static aspect Inner extends A {}
  42. }