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.

Code2.java 668B

1234567891011121314151617181920212223242526
  1. import org.aspectj.lang.annotation.*;
  2. public class Code2 {
  3. public void emitGooeyMess(String argument) throws Exception {
  4. throw new RuntimeException("Gooey Mess");
  5. }
  6. public static void main(String []argv) {
  7. try {
  8. new Code2().emitGooeyMess("ewwww");
  9. } catch (Exception e) {}
  10. }
  11. }
  12. @Aspect
  13. class TestAspect {
  14. @Pointcut("execution(* Code2.*(..)) && args(s)")
  15. public void squidStringMethods(String s) {}
  16. @AfterThrowing(pointcut="squidStringMethods(s)", throwing="e")
  17. public void catchGooeyMess(String s, Exception e) {
  18. //public void catchGooeyMess(String s, Exception e) {
  19. System.out.println("Catching mess. Argument was " + s);
  20. }
  21. }