[[invariant:intro|Intro]]
[[invariant:ex1|Ex1]]
[[invariant:ex2|Ex2]]
[[invariant:ex3|Ex3]]
[[invariant:ex4|Ex4]]
[[invariant:ex5|Ex5]]====== Invariants: Sanitize input ======
**Task:** Pass ''tests.PointBounds''.
Instead of throwing an exception when one of the ''int'' fields of ''Point'' is set to a negative value, write an aspect to trim the value to zero.
**Tools:** ''around'' advice; note that inside the body of an ''around'' advice, you can invoke a ''proceed'' statement with (possibly different) join point parameters.
Your aspect is going to look like this:
public aspect Answer4 {
void around(int val): {
proceed(val);
}
}
With a correct implementation, you should pass ''tests.PointBounds''.
----
When done, remove your aspect from the build path and continue with [[invariant:ex5|Exercise 5]].