JDefProg

defensive programming & design by contract for java

What is JDefProg and How it works?

JDefProg is a set of tools that "extends" Java in a transparent way. Using a set of annotations let the developers declare constraints on the code such "this parameter should be not null" or "after this method is called this condition has to be true". One of the components of JDefProg (the Annotations Processor) check the code and signal errors directly in your favorite IDE. Then the code to enforce this constraints is generated automatically and inserted into the compiled class files. It can ben done in two ways: weawing the physical class file (so modifying them permanently) or modifying the classes at load time.

Is a tutorial available?

Yes, just follow the link. You can also just download the latest release: it contains the tutorial. The download page is here.

Target of the project

The project is intended to provide an implementation of design by contract for Java.

The target is to create something a similar as possible to an extension of the language but keeping compatibility with java and using standard tools, in particular:
  • the constraint code has to be expressed in a language with a syntax very similar to java presenting   some extensions and limitations that make it suitable for the objective.
  • the constraint code has to be validated at compile time and error signaled directly into the IDE. the verification of the constraints has to be as fast as possible
  • correct inheritance of constraints has to be achieved
  • the project does not intend to implement a formal specification framework but just and exactly support for design by contract