Jcontract Quick Fact Sheet
What is Jcontract?
Jcontract is a non-intrusive package that allows you to use Design by Contract with Java. The package allows the expression of the code's contracts (i.e.
pre and post conditions) using Java code embedded in special Javadoctags.
Jcontract contains the following modules:
- dbc_javac: Java compiler that generates instrumented .class files
with extra code to check at runtime the contracts specified in the Javadoc
- Runtime: runtime that checks and monitors the contracts at runtime.
- Monitor: monitor that shows the progress of the instrumented program
and any violations found. Jcontract provides both a GUI and a line mode
What does Jcontract do?
Jcontract verifies that your class works correctly when it interacts
with other classes at the system level, and verifies that your class is
being used correctly at the system level.
How does Jcontract work?
Jcontract instruments and compiles your Design By Contract (DbC) commented Java code and reads
the DbC specification comments in your class's code. You then integrate
your class into the system and Jcontract checks it at runtime.
Jcontract monitors your class at runtime and ensures that it interacts with
other classes correctly at the system level and is being used
correctly at the system level.
How is Jcontract different from Jtest?
Jcontract tests classes at the system level to ensure that they
interact with other classes correctly and that are used by the system
correctly. Jtest tests a class at the unit level to ensure that it is
constructed properly, and its functionalities are working propery.
When in the development cycle is it best to use Jcontract?
The best time to use Jcontract would be immediately after you have
completed testing all of your classes/components at the unit level and are
ready to integrate the instrumented classes/components into your system.