Contract Inheritance

C4J supports full contract inheritance, both for target classes and for contracts themselves. If a class is protected by a contract, all extending classes will automatically enforce those contracts as well. Also, if a parent class is protected by a contract and an extending class is protected by another contract, the contracts will be combined for the extending class. Furthermore, contracts defined for super interfaces to interfaces that a class implements will also be enforced.

Contract inheritance in C4J works as follows:

If contracts don't adhere to these rules, it will be discovered during run time and a warning will be printed.