[[invariant:intro|Intro]]
[[invariant:ex1|Ex1]]
[[invariant:ex2|Ex2]]
[[invariant:ex3|Ex3]]
[[invariant:ex4|Ex4]]
[[invariant:ex5|Ex5]]====== Invariants: Find old tracing ======
**Task:** Signal an error for output on the standard output channel ''System.out''.
We typically use the idiom ''System.out.println()'' for one-off debugging traces. It's a common mistake to leave these in your system far longer than is necessary. Create an aspect with the implementation given below to signal an error at compile time if this mistake is made.
package answers;
aspect Answer1 {
declare error:
get(java.io.PrintStream System.out) && within(figures..*):
"Illegal access to System.out";
}
Note that this answer does not say that the call to the ''println()'' method is incorrect, rather, that the field get of the ''out'' field is illegal. Indeed, it is not a mistake in general to use the ''println()'' method.
When you use this on the given system, you'll find one incorrect trace in ''SlothfulPoint''.
----
Comment out the offending output line and continue with [[invariant:ex2|Exercise 2]].