User Tools

Site Tools


invariant:ex3

This is an old revision of the document!


Invariants: Preconditions

Point Precondition

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 case of tests.Test2a 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. 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.
invariant/ex3.1172471801.txt.gz · Last modified: 2007/02/26 07:36 by bdefrain