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.

TypeBug.java 896B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. class TypeBug {
  2. public static void main(String[] args) {
  3. new TypeBug().go();
  4. }
  5. A a = new A();
  6. D d = new D();
  7. G g = new G();
  8. void go(){
  9. g.foo(a);
  10. g.foo(d);
  11. bar(g);
  12. bash(g);
  13. }
  14. void bar(I i){
  15. i.foo(a);
  16. }
  17. void bash(J j){
  18. j.foo(d);
  19. }
  20. }
  21. aspect Q {
  22. pointcut pc1(): receptions(void I.foo(*));
  23. pointcut pc2(): calls(void I.foo(*));
  24. pointcut pc3(): callsto(pc1());
  25. pointcut test():;
  26. static before(): pc1() {
  27. System.out.print("(pc1) ");
  28. }
  29. static before (): pc2() {
  30. System.out.print("(pc2) ");
  31. }
  32. static before(): pc3(){
  33. System.out.print("(pc3) ");
  34. }
  35. }
  36. class A {}
  37. class D {}
  38. interface I {
  39. void foo(A a);
  40. }
  41. interface J {
  42. void foo(D d);
  43. }
  44. class G implements I, J {
  45. public void foo(A a){
  46. System.out.println("G.foo(A)");
  47. }
  48. public void foo(D d){
  49. System.out.println("G.foo(D)");
  50. }
  51. }