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.

Simple.java 728B

12345678910111213141516171819202122232425262728293031
  1. import org.aspectj.testing.Tester;
  2. public class Simple {
  3. public static void main(String[] args) {
  4. new C().foo();
  5. }
  6. }
  7. class C {
  8. private int privateField = 1;
  9. private int privateMethod() {
  10. return 42;
  11. }
  12. public void foo() {
  13. System.out.println("f: " + privateField);
  14. }
  15. }
  16. privileged aspect A {
  17. static before (C c): instanceof(c) && receptions(void foo()) {
  18. System.out.println("from A: " + c.privateField);
  19. c.privateField += 1;
  20. System.out.println("from A: " + c.privateField);
  21. System.out.println("from A: " + ++c.privateField);
  22. System.out.println("from A: " + c.privateField++);
  23. System.out.println("from A: " + c.privateField);
  24. System.out.println("from A: " + c.privateMethod());
  25. }
  26. }