package figures; aspect FactoryEnforcement { pointcut illegalNewFigElt(): call(FigureElement+.new(..)) && !withincode(FigureElement+ Figure.make*(..)); /* * declare error is not described in the CACM article. It is a * special declarative form of advice that says "Throw an error * at any join point matched by the specified pointcut, and * throw that error at compile time." This is useful for aspects * like this one that check design invariants in your code. * * See the comment in Main.java that says how to demonstrate the * effect of this aspect. */ declare error: illegalNewFigElt(): "Illegal figure element constructor call."; }