We present a technique for automatically weaving structural invariant checksinto an existing collection of classes. Using variations on existing designpatterns, we use a concise specification to generate from this collection a newset of classes that implement the interfaces of the originals, but with theaddition of user-specified class invariant checks. Our work is notable in thescarcity of assumptions made. Unlike previous design pattern approaches to thisproblem, our technique requires no modification of the original source code,relies only on single inheritance, and does not require that the attributesused in the checks be publicly visible. We are able to instrument a widevariety of class hierarchies, including those with pure interfaces, abstractclasses and classes with type parameters. We have implemented the constructionas an Eclipse plug-in for Java development.
展开▼