Jon's Assertion Package

Jon's Assertion Package is tool that allows the use of Design by Contract with Java. More information can be found in the README and in the api documentation.

What is Design by Contract?

The basic idea of Design by Contract is that someone can write a piece of code with a particular usage in mind and can then document the usage and then enforce this during development and remove these checks when releasing production code. This is accomplised by using inline assertions, just like assert.h in C, pre conditions, post conditions and invariants. Each condition is a boolean statement that "asserts" that something is true when a piece of code is being executed. Pre conditions assert that a condition is true at the start of execution of a method. Post conditions are for a condition being true at the end of a method. Invariants are conditions that must be true for before and after all public methods in a class are called, in the case of this tool all methods that aren't private. These conditions are also inherited so that someone can define conditions for use of a superclass and all subclasses follow this as well. The way that this is done is by evaluating all of the conditions for a method on one class then either AND or OR this result with the next class in the inheritance tree depending on the type of assertion so that the burden is placed on the person using the method rather than the person writing the method. The following table shows the rules.

Type of assertion Logical operation performed for inherited conditions
invariant AND
precondition OR
postcondition AND

Why write this?

I wrote this program because I've used a program in the past called AssertMate and it really didn't implement assertions very well and had a lot of bugs. I talked with the people that wrote it and they decided to stop development, so I decided that being the programmer that I am, I'd write my own. Little did I know how much I was getting into, I've written compilers before, but this is a little more difficult, I actually have to modify someone else's code and it still needs to work the way they intended.

Download

Ok, I've got a real release again. At least as real as it's going to get. You need jdk-1.2.x or better to run/compile this. You'll also need the following jar files. I've listed the primary sitesto give proper credit to the authors that wrote these great packages. You can see the major changes here. For a full list of changes see ChangeLog.

If you happen to use Ant then you'll be interested in this build.xml file. It's got an example of how to tie JonsAssert into an ant build.

Usage

	java -classpath "JonsAssert-0.5.4.jar:JonsInfra-0.2.jar:werken.opt.jar:antlr.jar" net.mtu.eggplant.dbc.JonsAssert [options] files ...
    

See the API documentation for JonsAssert for commandline options


Valid XHTML 1.0! Valid CSS!

Jon Schewe

Last modified: Thu Feb 26 15:59:07 CST 2004