ESCJ 30: ESC/Java Refcard

Compiled by Silvija Seres, June 1999.

This document is intended to be a non-detailed, trimmed-down version of the ESC/Java user manual (ESCJ 27), for people who would like to get an overview of the expressive power of the ESC/Java annotation language without getting immersed in all its technical intricacies.  It can be a useful reading aid for examples of ESC/Java annotated programs.

For more detailed information, please refer to the ESC/Java user manual (ESCJ 27). For information about the invocation of the ESC/Java checker, please see the escjava(1) man page (ESCJ 26).

What does ESC/Java do anyway?

Type annotation and static type checking of programs have proved to be one of biggest engineering successes of computer science. Typing provides a coarse semantics for programs, since it pays no attention to the semantics of any language constructs that are not related to types. Nevertheless, the automatic type checking of programs weeds out already at compile time many of the most common programming errors, thus making them less costly for the developers. Also, typing forces a certain discipline upon the programmer, which results in better programs.

The ESC/Java language is pushing the idea behind type checkers a few steps further. The class of errors that it looks for is much larger and more varied: it addresses, among others, the potential run-time errors that arise from illegal array operations, null-pointer dereferencing, deadlocks and race conditions of threads. Given a Java program, it automatically infers and checks a set of verification conditions that correspond to the described classes of errors. Furthermore, it also allows the programmer to record design decisions, and to influence the choice of verification conditions by annotating the program with a set of pragmas. These can be used to specify the pre- and post-conditions of routines, modifications of global variables, properties of abstract-data types, invariants of loops, and much more.

The errors that ESC/Java looks for are chosen on a pragmatic basis; they are the errors that, according to the engineering experience, occur often and are relatively cheap to find, but the ESC/Java system is flexible and can be extended to allow for checking of other types of errors. Presently, ESC/Java is checking Java 1.0 code and only a subset of the new Java 1.1 features, and the upgrading is a subject of current work.

In terms of program verification, ESC/Java is unsound, because it can miss real programming errors (from the specified class), and it is incomplete, because it can give some spurious warnings. Some unsoundness will always occur in automated tools like ESC/Java as a result of a tradeoff between the efficiency of the tool and its semantical completeness. Even so, ESC/Java shows an unprecedented level of semantical accuracy combined with automation. The user has some control over ESC/Java's incompleteness thanks to pragmas. These pragmas not only enable modular program verification, but are also a convenient formalism for recording programmers' design decisions and program specifications.

The remainder of this page describes the pragmas available in the current ESC/Java checker and the other concepts used in the pragma annotations.

There are four syntactic categories of ECS/Java pragmas:

A pragma is enlosed in a Java comment whose first character is an @. For example, /*@ non_null */ is a ESC/Java pragma.

The list of ECS/Java pragmas with their (syntactic, semantic) contexts:

The semicolon is a pragma separator, not a terminator.

The ESC/Java specification expressions:

A specification type is either a Java type or one of the special types TYPE or LockSet (or an array of special types, for example TYPE[][]). The specification type LockSet cannot be mentioned in annotations.

Specification expressions must be free of subexpressions that may potentially have side effects, so they may not contain any assignment (=, +=, etc.), pre/post-increment/decrement (++ or --), array or object creation (new), or method invocation.

The additional constructs that are allowed in specification expressions beyond those allowed in Java expressions are:

The ESC/Java warning types:

ESC/Java issues warnings for conditions that it regards as run-time errors, and that, so far is it can tell, might actually occur at run-time.

The ESC/Java modification targets (or specification designators):

Legal Statement Privacy Statement