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.

Driver.java 804B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import org.aspectj.testing.Tester;
  2. /**
  3. * This does accessibility of class and class variables, both inherited
  4. * and non-inherited, in the body of a weave.
  5. */
  6. public class Driver {
  7. public static void main(String[] args) { test(); }
  8. public static void test() {
  9. Tester.checkEqual((new Bar()).m(), 10, "Bar.m");
  10. }
  11. }
  12. class Foo {
  13. int fooVar = 1;
  14. public int getFooVar( ) { return fooVar; }
  15. }
  16. class Bar extends Foo {
  17. int barVar = 2;
  18. int ans = 0;
  19. public int getBarVar() { return barVar; }
  20. public void setAns( int newAns ) { ans = newAns; }
  21. int m() {
  22. return ans;
  23. }
  24. }
  25. abstract aspect A {
  26. static int aVar = 3;
  27. }
  28. aspect B extends A {
  29. static int bVar = 4;
  30. before(Bar b): target(b) && call(* m(..)) {
  31. b.setAns(b.getFooVar() + b.getBarVar() + aVar + bVar);
  32. }
  33. }