User Tools

Site Tools


invariant:ex3

This is an old revision of the document!


Invariants: Preconditions

Point Preconditions

Task: Pass the suite tests.PointPreconditions.

Write an aspect to throw an IllegalArgumentException whenever an attempt is made to set one of the int fields of a Point to a value that is less than zero.

Tools: before advice with set and args primitive pointcuts.

This should make the test cases of tests.PointPreconditions pass, which wouldn't without your aspect.

Group Preconditions

Task: Pass the suite tests.GroupPreconditions.

Group is a FigureElement class that encapsulates groups of other figure elements. As such, only actual figure element objects should be added to Group objects. Also, a group cannot be added to itself. Write an aspect to throw an IllegalArgumentException whenever an attempt is made to call Group.add() on a null value, or on the group itself.

Tools: call and args primitive pointcuts; target primitive pointcut to capture the target of the add() call.

This should make the test cases of tests.GroupPreconditions pass.


Remove your aspect from the build path; then continue with Exercise 4.

invariant/ex3.1172478828.txt.gz · Last modified: 2007/02/26 09:33 by bdefrain