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.

PR353c.java 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. import org.aspectj.testing.*;
  2. import java.util.*;
  3. public class PR353c {
  4. public static void main(String[] args){
  5. new PR353c().go();
  6. }
  7. void go(){
  8. C c = new C(); c.f(); c.g();
  9. A a = new A(); a.f(); a.g();
  10. B b = new B(); b.f(); b.g();
  11. D d = new D(); d.f(); d.g();
  12. E e = new E(); e.f(); e.g();
  13. }
  14. }
  15. interface I { }
  16. class C {
  17. void f() {}
  18. void g() {}
  19. }
  20. class A extends C {
  21. void f() {}
  22. }
  23. class B extends C {
  24. void f() {}
  25. void g() {}
  26. }
  27. class D extends C { }
  28. class E extends C implements I { }
  29. aspect AA extends AspectSupport {
  30. pointcut f(): receptions(void f());
  31. pointcut g(): receptions(void g());
  32. pointcut b(): f() || g();
  33. pointcut all(): b();
  34. pointcut notC(): b() && !instanceof(C);
  35. pointcut notD1(): b() && instanceof(C) && !instanceof(D);
  36. pointcut notD2(): b() && !instanceof(D) && instanceof(C);
  37. pointcut notI(): b() && !instanceof(I);
  38. pointcut notA1(): b() && instanceof(C) && !instanceof(A);
  39. pointcut notA2(): b() && !instanceof(A) && instanceof(C);
  40. pointcut notB1(): b() && instanceof(C) && !instanceof(B);
  41. pointcut notB2(): b() && !instanceof(B) && instanceof(C);
  42. pointcut notE1(): b() && instanceof(C) && !instanceof(E);
  43. pointcut notE2(): b() && !instanceof(E) && instanceof(C);
  44. static before(): all() { p("cabde", thisJoinPoint.className); }
  45. static before(): notC() { p("", thisJoinPoint.className); }
  46. static before(): notD1() { p("cabe", thisJoinPoint.className); }
  47. static before(): notD2() { p("cabe", thisJoinPoint.className); }
  48. static before(): notI() { p("cabd", thisJoinPoint.className); }
  49. static before(): notA1() { p("cbde", thisJoinPoint.className); }
  50. static before(): notA2() { p("cbde", thisJoinPoint.className); }
  51. static before(): notB1() { p("cade", thisJoinPoint.className); }
  52. static before(): notB2() { p("cade", thisJoinPoint.className); }
  53. static before(): notE1() { p("cadb", thisJoinPoint.className); }
  54. static before(): notE2() { p("cadb", thisJoinPoint.className); }
  55. pointcut _b(): receptions(* *());
  56. pointcut _all(): _b();
  57. pointcut _notC(): _b() && !instanceof(C);
  58. pointcut _notD1(): _b() && instanceof(C) && !instanceof(D);
  59. pointcut _notD2(): _b() && !instanceof(D) && instanceof(C);
  60. pointcut _notI(): _b() && !instanceof(I);
  61. pointcut _notA1(): _b() && instanceof(C) && !instanceof(A);
  62. pointcut _notA2(): _b() && !instanceof(A) && instanceof(C);
  63. pointcut _notB1(): _b() && instanceof(C) && !instanceof(B);
  64. pointcut _notB2(): _b() && !instanceof(B) && instanceof(C);
  65. pointcut _notE1(): _b() && instanceof(C) && !instanceof(E);
  66. pointcut _notE2(): _b() && !instanceof(E) && instanceof(C);
  67. static before(): _all() { p("cabde", thisJoinPoint.className); }
  68. static before(): _notC() { p("", thisJoinPoint.className); }
  69. static before(): _notD1() { p("cabe", thisJoinPoint.className); }
  70. static before(): _notD2() { p("cabe", thisJoinPoint.className); }
  71. static before(): _notI() { p("cabd", thisJoinPoint.className); }
  72. static before(): _notA1() { p("cbde", thisJoinPoint.className); }
  73. static before(): _notA2() { p("cbde", thisJoinPoint.className); }
  74. static before(): _notB1() { p("cade", thisJoinPoint.className); }
  75. static before(): _notB2() { p("cade", thisJoinPoint.className); }
  76. static before(): _notE1() { p("cadb", thisJoinPoint.className); }
  77. static before(): _notE2() { p("cadb", thisJoinPoint.className); }
  78. }
  79. class Verifier {
  80. void verify(Map map) {
  81. Iterator iter = map.keySet().iterator();
  82. while (iter.hasNext()) {
  83. String key = (iter.next() + "").toLowerCase();
  84. List list = (List) map.get(key);
  85. Iterator it = list.iterator();
  86. while (it.hasNext()) {
  87. Object onext = it.next();
  88. String next = (onext + "").toLowerCase();
  89. if (key.indexOf(next) == -1) {
  90. Tester.check(false, next + " not found in " + key);
  91. } else {
  92. it.remove();
  93. }
  94. }
  95. Tester.check(list.size() == 0, list + " contains classes excluded");
  96. }
  97. }
  98. }
  99. aspect AspectSupport {
  100. public static Map map = new HashMap();
  101. static {
  102. String[] ss = {
  103. };
  104. for (int i = 0; i < ss.length; i++) {
  105. map.put(ss[i], new Vector());
  106. }
  107. }
  108. static void p(String key, String str) {
  109. List list = (List) map.get(key);
  110. if (list == null) {
  111. list = new Vector();
  112. }
  113. list.add(str);
  114. map.put(key, list);
  115. }
  116. static List v(Object[] os) {
  117. List v = new Vector();
  118. for (int i = 0; i < os.length; i++) {
  119. v.add(os[i]);
  120. }
  121. return v;
  122. }
  123. }