/* testing aspectj 1.2 - compile with ajc */ public class simpleobj { private int x; public simpleobj(int a) { x=a; } public void incx() { x++; } public int f() {return x*x;} public static void main(String[] args) { simpleobj S = new simpleobj(1); simpleobj T = new simpleobj(100); S.incx(); T.incx(); int x = T.f(); } } // simple privileged aspect checkitout { after(int i) : execution(simpleobj.new(..)) && args(i) { System.out.println("A simple object was created with x=="+i); } before(simpleobj A) : call(void simpleobj.incx()) && target(A) { System.out.println("incx() being invoked on object at "+ (Object)A); } void around(simpleobj A) : call(void simpleobj.incx()) && target(A) { if (A.x<10) proceed(A); else System.out.println("x is already too big"); } after() returning (int x) : call(int simpleobj.f()) { System.out.println("f returned "+x); } }