Search
Google

ContractJ

The goal of this project is to employ the Design-by-Contract principle on the Java programming language. The solution will use a perprocessor to statically weave contract checks into the code. At the moment only some experiments were made and I wrote a list of requirements, goals and methods of resolution. The preprocessor is developed independently in the JLFX project. Currently I am working on the preprocessor which is why the ContractJ project will still be idle for a while.

Goals

When ready, ContractJ shall offer the features pf Design-by-Contract as known from the programming language Eiffel for Java. In the DBC principle, conditions are formulated that an object or a class must satisfy, either every time or after certain operations. These conditions form the contract a class satisfies. Contracts are inherited by subclasses. Using the DBC principle classes not only offer a syntactical interface but also a semantical on which a programmer can rely. Contracts have to be checked at runtime. You can find more info on DBC in an introduction to Eiffel.

There are other approaches for employing DBC on java, I know: iContract and Jass. These approaches all have their strengths and weaknesses. One goal of mine is to bring together the strengths and add some new ideas. One important part of my solution will be the support of generic classes as proposed in the Java Specification Request 14. I have already developed a few prototypes for a DBC preprocessor, which all aren't fully functional. Out of these experiences I have listed some requirements, goals and methods of resolution. This brainstorming is only available in german at the moment.

I am just working on a preprocessor, that can be used to implement ContractJ. Although this preprocessor started out as a part of ContractJ, I decided to extend it to become a framework for extending the Java language. My work on ContractJ will thus be deferred until this framework is ready.