// must compile together with security and extensionmethod aspects privileged aspect extendinterface // add method to existing interface { public abstract void stuinterface.whine(); public void student.whine() { System.out.println("2pm is too early for me! Too much math!"); } student s; // instance of student to be captured on creation after(student stu) : execution(public student+.new(..)) && target(stu) { s = stu; } // capture student instance to be used in next advice: after() : execution(public static void *.main(String[])) { System.out.print(s.name+" is whining: "); s.whine(); s.changeGPA(4.0); // used with next aspect } } // precedence of aspects can be declared thus (compiler will detect cycles): /* aspect orderaspects { declare precedence: extendinterface, *; // give this advice precedence } // over all others */ // commented out because of conflict with another declaration