// Cross cutting aspects of the program: (for base aop18.java) aspect trace // trace the construction of each object, plus run function { // after advice after(Object c) : (execution(student+.new(..)) || execution(pc.new(..)) || execution(vehicle.new(..))) && target(c) && !adviceexecution() { System.out.println("Object created: "+c ); } }//trace /* executiong(student+.new(.._)) refers to the joinpoint where a new instance of student, or subclass of student is being created. '+' includes subclass and new(..) refers to any constructor. If we want to refer a specific constructor, we have to specify its signature more carefully: new(int) or new(String,..) Note that unlike the other advice, here we use 'execution' instead of 'call': There is no 'target' object being created at the call site until the constructor call returns. Generally, use 'execution' instead of 'call' to refer to calling a constructor, or calling main. If you say after(...) : call(public static *.void(main(..)), your advice will never execute because the program doesn't exist anymore after main. */