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.

PR318.java 659B

12345678910111213141516171819202122232425262728293031323334
  1. public class PR318 {
  2. public static void main(String[] args) {
  3. new PR318().realMain(args);
  4. }
  5. public void realMain(String[] args) {
  6. Bar.bar();
  7. org.aspectj.testing.Tester.check(caught, "Exception wasn't caught");
  8. }
  9. static boolean caught = false;
  10. }
  11. class Foo {
  12. static void foo () throws Exception {
  13. throw new IllegalArgumentException("foo!");
  14. }
  15. }
  16. class Bar {
  17. static void bar () {
  18. try {
  19. Foo.foo();
  20. } catch (Exception e) {
  21. }
  22. }
  23. }
  24. aspect A {
  25. before (Exception e): handler(Exception) && args(e) {
  26. if (e instanceof IllegalArgumentException) {
  27. PR318.caught = true;
  28. }
  29. }
  30. }