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.

AfterLock.java 678B

12345678910111213141516171819202122232425262728293031
  1. // after advice and lock
  2. public aspect AfterLock {
  3. after(Foo f): lock() && this(f) {
  4. System.err.println("after(Foo) lock: advice running at "+thisJoinPoint.getSourceLocation());
  5. }
  6. after(): lock() {
  7. System.err.println("after() lock: advice running at "+thisJoinPoint.getSourceLocation());
  8. }
  9. public static void main(String[] args) {
  10. Foo aFoo = new Foo();
  11. aFoo.staticM();
  12. aFoo.nonstaticM();
  13. }
  14. static class Foo {
  15. public void nonstaticM() {
  16. synchronized (this) {
  17. System.err.println("non-static method running");
  18. }
  19. }
  20. public static void staticM() {
  21. synchronized (String.class) {
  22. System.err.println("static method running");
  23. }
  24. }
  25. }
  26. }