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.

NotCharInPointcut.java 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // PR#208 ! modifier in pointcut
  2. public class NotCharInPointcut {
  3. public static void main(String[] args) throws Exception {
  4. for (int i = 0; i < methods.length; i++) {
  5. org.aspectj.testing.Tester.expectEvent(methods[i]);
  6. C.class.getMethod(methods[i], new Class[]{}).
  7. invoke(new C(), new Object[]{});
  8. }
  9. }
  10. final static String[] methods = {
  11. "_void",
  12. "_boolean",
  13. "_byte",
  14. "_char",
  15. "_short",
  16. "_int",
  17. "_long",
  18. "_float",
  19. "_double",
  20. "_Object",
  21. };
  22. }
  23. class C {
  24. private void s(String s) { org.aspectj.testing.Tester.event(s); }
  25. public void _void() { s("_void"); }
  26. public boolean _boolean() { s("_boolean"); return (boolean)false;}
  27. public byte _byte() { s("_byte"); return (byte)0;}
  28. public char _char() { s("_char"); return (char)0;}
  29. public short _short() { s("_short"); return (short)0;}
  30. public int _int() { s("_int"); return (int)0;}
  31. public long _long() { s("_long"); return (long)0;}
  32. public float _float() { s("_float"); return (float)0;}
  33. public double _double() { s("_double"); return (double)0;}
  34. public Object _Object() { s("_Object"); return this; }
  35. }
  36. aspect A {
  37. pointcut pcut1(NotCharInPointcut t):
  38. this(t) && execution(!* _*());
  39. pointcut pcut2(NotCharInPointcut t):
  40. this(t) && !this(NotCharInPointcut) && execution(!* _*());
  41. pointcut pcut3(NotCharInPointcut t):
  42. pcut1(t) || pcut2(t);
  43. before(NotCharInPointcut t): pcut1(t) { s("1:"+thisJoinPoint); }
  44. before(): pcut2(*) { s("2:"+thisJoinPoint); }
  45. before(NotCharInPointcut t): pcut3(t) { s("3:"+thisJoinPoint); }
  46. private final static void s(Object s) {
  47. org.aspectj.testing.Tester.check(false, "should be in "+s);
  48. }
  49. }