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.

TryFinallyInAround.java 838B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import org.aspectj.testing.Tester;
  2. // XXX broken in 1.1rc1, fixed in tree as of 4/22
  3. /** @testcase try/finally in around advice (same as ...messy arounds?) */
  4. public class TryFinallyInAround {
  5. public static void main(String[] args) {
  6. int i = new C().go();
  7. Tester.check(2 == i, "expected 2 got " + i);
  8. }
  9. }
  10. class C {
  11. int i = 1;
  12. int go() {
  13. dowork();
  14. return i;
  15. }
  16. void dowork() {
  17. i++;
  18. }
  19. }
  20. aspect A {
  21. Object around() :
  22. within(C)
  23. && !cflow(within(A))
  24. && !handler(*)
  25. && !preinitialization(new(..)) // 1.1
  26. && !initialization(new(..))
  27. {
  28. // no bug if reduced to proceed();
  29. try {
  30. return proceed();
  31. } finally {
  32. if (false) System.out.println("ok");
  33. }
  34. }
  35. }