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.

MyApplication.aj 743B

123456789101112131415161718192021222324252627
  1. package edu.ucsd.aosd;
  2. import java.io.PrintStream;
  3. public class MyApplication
  4. {
  5. // main
  6. public static void main(String[] args) {
  7. for (String arg : args) {
  8. System.out.println("got: " + arg);
  9. System.out.printf("got: %s\n", arg);
  10. }
  11. }
  12. }
  13. aspect Printing {
  14. pointcut printlnCalls(PrintStream ps, String out):
  15. call(* PrintStream+.println(String)) && target(ps) && args(out);
  16. Object around(PrintStream ps, String out):
  17. printlnCalls(ps, out) && !adviceexecution() {
  18. return proceed(ps, out);
  19. }
  20. pointcut printfCalls(PrintStream ps, String fmt, Object[] objs):
  21. call(* PrintStream+.printf(String, Object...))
  22. && target(ps) && args(fmt, objs);
  23. }