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.

NotAndDeclaringTypes.java 776B

12345678910111213141516171819202122232425262728293031323334353637
  1. import org.aspectj.testing.Tester;
  2. public class NotAndDeclaringTypes {
  3. public static void main (String args []) {
  4. Rectangle r = new Rectangle ();
  5. Square s = new Square ();
  6. r.getSurface();
  7. Tester.checkAndClearEvents(new String[] { "advice" });
  8. s.getSurface();
  9. Tester.checkAndClearEvents(new String[] { });
  10. }
  11. }
  12. class Rectangle {
  13. public String toString () { return "Rectangle"; }
  14. public int getSurface () { return 100; }
  15. }
  16. class Square extends Rectangle {
  17. public String toString () { return "Square"; }
  18. public int getSurface () { return 200; }
  19. }
  20. aspect Concern {
  21. pointcut pc () : call (int Rectangle.getSurface ())
  22. && !call (int Square.getSurface ());
  23. before () : pc () {
  24. Tester.event("advice");
  25. }
  26. }