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.

ThisJoinPointUnlock.java 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import org.aspectj.lang.reflect.*;
  2. aspect TJPAspect {
  3. before(): withincode(void ThisJoinPointUnlock.nonStaticMethod()) {
  4. if (thisJoinPoint.getSignature() instanceof UnlockSignature) {
  5. System.err.println("match.toString(): "+thisJoinPoint.toString());
  6. System.err.println("match.toShortString(): "+thisJoinPoint.toShortString());
  7. System.err.println("match.toLongString(): "+thisJoinPoint.toLongString());
  8. }
  9. // SHORT => shorttypenames, no args, no throws, no modifiers, short type names
  10. // MIDDLE=> args included
  11. // LONG => modifiers included
  12. }
  13. // before(): withincode(void ThisJoinPointLock.nonStaticMethod()) {
  14. // if (thisJoinPoint.getSignature() instanceof MethodSignature) {
  15. // System.err.println("match.toString(): "+thisJoinPoint.toString());
  16. // System.err.println("match.toShortString(): "+thisJoinPoint.toShortString());
  17. // System.err.println("match.toLongString(): "+thisJoinPoint.toLongString());
  18. // }
  19. //
  20. // // SHORT => shorttypenames, no args, no throws, no modifiers, short type names
  21. // // MIDDLE=> args included
  22. // // LONG => modifiers included
  23. // }
  24. }
  25. public class ThisJoinPointUnlock {
  26. public static void main(String[] args) {
  27. ThisJoinPointUnlock b = new ThisJoinPointUnlock();
  28. b.nonStaticMethod();
  29. b.staticMethod();
  30. }
  31. public void nonStaticMethod() {
  32. synchronized (this) {
  33. staticMethod();
  34. }
  35. }
  36. public void staticMethod() {
  37. synchronized (ThisJoinPointUnlock.class) {
  38. }
  39. }
  40. }