Jtest logo




Contents  Previous  Next  Index

Welcome


Welcome to Jcontract, a tool that enables Design by Contract (DbC) in Java.

Jcontract instruments and compiles DbC-commented Java code, then automatically checks whether contracts specified in the DbC comments are violated at runtime. Jcontract is independent of Jtest, but the two tools are complementary. You can use Jtest to verify that the class or component is solid and correct at the unit-level, and you can use Jcontract to verify system-level functionality and check whether the system misuses specific classes or components.

Jcontract uses a unique dbc_javac compiler that is a Design by Contract-enabled replacement for javac; it checks the DbC specification in the Javadoc comments, generates instrumented .java files with extra code to check the contracts in the Javadoc comments, and compiles the instrumented .java files with the javac compiler. This process is completely transparent; the only difference between using javac and dbc_javac is that with dbc_javac, the resulting .class files are instrumented with extra bytecodes to check the contracts at runtime.

After files are compiled and instrumented, Jcontract checks the contracts at runtime, and reports any violations found and stack trace information in the Jcontract GUI Monitor, the Jcontract TEXT Monitor, or a file. This helps you determine exactly when and where a violation occurs.

Jcontract is completely customizable. By default, Jcontract uses a completely non-intrusive Runtime Handler that reports violations found, but does not alter program execution. You can also choose a Runtime Handler that throws exceptions when violations occur, choose a Runtime Handler that logs violations in a file, or create a customized Runtime Handler that is specially tailored to your unique needs.

It's also possible to embed the contract enforcing comments in your Javadoc and have these contracts enforced without any Jcontract runtime. No Jcontract libraries are required on the user side-- just compile all of the Java source with the command and flag dbc_javac -Zruntime_handler NONE. When contracts are violated, java.lang.RuntimeExceptions are thrown to stdout with the contract as the String message of the exception. This helps you debug your code without having to ship any Jcontract-related components.

Jcontract also adapts to your needs by letting you select which contract conditions you want it to instrument. This way, you can optimize application performance by having Jcontract only monitor the exact conditions that are relevant at your current stage of the development process. For example, after a well-tested class is integrated into the application, you might only want to instrument and check preconditions that verify whether the application uses the class correctly.


Contents  Previous  Next  Index

ParaSoft logo
(888) 305-0041 info@parasoft.com Copyright © 1996-2001 ParaSoft