My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
FAQ  
Frequently Asked Questions about Cofoja
Featured
Updated Jul 13, 2011 by chat...@google.com

Are there any pre-packaged JAR files I can download?

We now provide official snapshot builds of our development tree, available under the Downloads tab. However, please note that Cofoja is a very young project so be sure to check back for updates, in order to keep up with the most current changes and bug fixes.
The official builds are bundled with the ASM library and have self-contracts (contracts that we have put on Cofoja's own classes) turned on, to help us track bugs (see below, "are you eating your own dogfood?").
Alternatively, Nhat maintains a directory with snapshot builds in different flavours, built from his development branch: http://www.huoc.org/~minh/cofoja/ (Plain versions come bundled with ASM classes; -bare versions only contain Cofoja files. ccofoja builds have Cofoja's own contracts turned on.)

What do I need in order to use Cofoja?

Cofoja depends on Java 6 or higher for annotation processing and instrumentation support. The ASM package is also required and can be downloaded from: http://asm.ow2.org/ (Cofoja is being developed against version 3.3; A version higher than 3.2 is required.) Cofoja comes with an Ant script for compilation and a set of JUnit 3 tests.

How is this better than using assert?

  • Contracts are inherited from superclasses and interfaces.
  • Inherited contracts can be extended, but only within the limits imposed by the superclass -- as in the Liskov substitution principle.
  • @Ensures can use the old keyword to refer to the state at the start of the method, e.g. @Ensures("size() == old(size()) + 1").
  • @Invariant adds checks to every public method.
  • @ThrowEnsures adds checks about conditions when an exception is thrown.
  • Disabled by default -- so you can and should write expensive checks. Can be enabled all at once or selectively, i.e. just for a particular library or group of libraries.
  • Clean separation of assumptions and guarantees from the actual method code. The annotations become part of the javadoc.

Is this framework related to 'ModernJass' from Sourceforge.net?

Yes, Cofoja is a significant rewrite of ModernJass. We worked closely with the original author of ModernJass (Johannes Rieken) on this.

Is code annotated with contracts slower than code not annotated?

If runtime checking is enabled, yes. If runtime checking is disable the code is as fast as if there were no annotations.

Is the contract code compiled? I only see strings in annotations!

The annotation processor takes care of compiling the strings into bytecode and runs along the Java compiler, so you get static syntax and typing errors at compile time, as usual.

Is there any IDE support yet?

Not yet. The eclipse plugin from the ModernJass sourceforge.net page is obsolete. Let us know if you would like to help!

What about debugger support?

Contracts for Java adds standard debugging information, such as source file and line numbers, to contract code. Debugging has been tested under JDB, Eclipse and IntelliJ (using remote debugging); only Eclipse has issues with setting breakpoints on contract annotations (source correspondence and step-by-step debugging works, though).

Is the source code of Contracts for Java annotated with contracts? (I.e. are you eating your own dogfood?)

Yes, all the classes in Cofoja that could bear contracts have been contracted; some classes needed at run time cannot be annotated because of technical reasons. New classes are only added to the project with proper contracts.
Comment by sagarf...@gmail.com, Aug 3, 2011

How are the assertions of the type where they "compares two arrays are equal or not" are provided in cofoja?

Comment by project member chat...@google.com, Aug 5, 2011

Hope your question was answered in the list. Please use the mailing list for general questions, since it is much more likely to get answered and it keeps the questions organized :) Cheers


Sign in to add a comment
Powered by Google Project Hosting