Under the Hood of C4J

C4J use the new -javaagent switch that was added to Java 1.5. It provides a way to hook on to the class loader, and return custom byte code for any class that is loaded by the Java runtime. C4J contain an "instrumentor class" that instruments all loaded classes that defines a ContractReference annotation with contract verification code.
Javassist, an extremely easy to use byte code library, is used for instrumenting.

The C4J instrumentor class does the following on each class that is loaded:

For each method in the target class:

Apart from this there is more stuff going on if the contract extends ContractBase; return- and pre- values are made available to post conditions, and logging hooks are notified of all contract checking.