import org.aspectj.lang.*; import org.aspectj.lang.reflect.*; aspect BoundaryChecker { pointcut growPoint(DataStructure s): call(public void DataStructure.push(Object)) && target(s); pointcut shrinkPoint(DataStructure s): call(public Object DataStructure.pop()) && target(s); void around(DataStructure s) throws java.lang.ArrayIndexOutOfBoundsException : growPoint(s) { int pos, size; pos = s.pos; size = s.size; if (pos == size) throw(new ArrayIndexOutOfBoundsException()); System.out.println("push"); proceed(s); } Object around(DataStructure s) throws java.lang.ArrayIndexOutOfBoundsException : shrinkPoint(s) { int pos; pos = s.pos; if (pos < 0) throw(new ArrayIndexOutOfBoundsException()); System.out.println("pop"); return proceed(s); } }