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.

AroundExceptions.java 714B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import org.aspectj.testing.Tester;
  2. import java.io.IOException;
  3. public class AroundExceptions {
  4. public static void main(String[] args) {
  5. new SubC().m();
  6. Tester.checkAndClear("around-reception caught-IOException", "subc.m");
  7. new C().m();
  8. Tester.checkAndClear("around-reception", "c.m");
  9. }
  10. }
  11. class C {
  12. public void m() throws IOException {
  13. }
  14. }
  15. class SubC extends C {
  16. public void m() throws IOException {
  17. throw new IOException();
  18. }
  19. }
  20. aspect A {
  21. void around (): call(void C.m()) {
  22. Tester.note("around-reception");
  23. proceed();
  24. }
  25. void around(): call(void C+.m()) {
  26. try {
  27. proceed();
  28. } catch (IOException ioe) {
  29. Tester.note("caught-IOException");
  30. }
  31. }
  32. }