Java Modeling Language

Java Modeling Language

The Java Modeling Language (JML) follows the design by contract paradigm. It is a specification language for Java programs, using .

There are various verification tools for JML, such as a runtime assertion checker and the Extended Static Checker (ESC/Java).

Overview

JML is a behavioural interface specification language for Java modules. This means that JML provides semantics to formally describe the behaviour of a Java module, removing potential ambiguity with regard to the module designers' intentions. JML inherits ideas from Eiffel, Larch and the Refinement Calculus, with the goal of providing rigorous formal semantics while still being accessible to any Java programmer. Specifications can be written as annotations in Java program files, or stored in separate specification files. Various tools are available that make use of the extra behavioural information that JML specifications provide, and, because JML annotations take the form of Java comments, whether embedded in Java code or in separate files, Java modules with JML specifications can be compiled unchanged with any Java compiler.

Syntax

JML specifications are added to Java code in the form of annotations in comments. Java comments are interpreted as JML annotations when they begin with an @ sign. That is, comments of the form

//@

or

/*@ @*/

Basic JML syntax provides the following keywords

; requires : Defines a precondition on the method that follows.; ensures : Defines a postcondition on the method that follows.; signals : Defines a condition on when a given Exception can be thrown by the method that follows.; assignable : Defines which fields are allowed to be assigned to by the method that follows.; pure : Declares a method to be side effect free (this shorthand for assignable othing).; invariant : Defines an invariant property of the class.; also : Declares that a method should inherit conditions from its supertypes.; assert : Defines a JML assertion.

Basic JML also provides the following expressions

; esult : An identifier for the return value of the method that follows.; old() : A modifier to refer to the value of variable at the time of entry into a method.; forall : The universal quantifier.; exists : The existential quantifier.; a => b : The logical construct a implies b; a <=> b : The logical construct a if and only if b

as well as standard Java syntax for logical and, or, and not. JML annotations also have access to Java objects, object methods and operators that are within the scope of the method being annotated. These are combined to provide formal specifications of the properties of classes, fields and methods. For example, an annotated example of a simple banking class may look like

public class BankingExample { public static final int MAX_BALANCE = 1000; private int balance; private boolean isLocked = false; //@ invariant balance >= 0 && balance <= MAX_BALANCE; //@ assignable balance; //@ ensures balance = 0; public BankingExample() { ... } //@ requires amount > 0; //@ ensures balance = old(balance) + amount; //@ assignable balance; public void credit(int amount) { ... } //@ requires amount > 0; //@ ensures balance = old(balance) - amount; //@ assignable balance public void debit(int amount) { ... } //@ ensures isLocked = true; public void lockAccount() { ... } //@ signals (BankingException e) isLocked; public /*@ pure @*/ int getBalance() throws BankingException { ... } }

Full documentation (as of 2005, currently still in development) of JML syntax is available [http://www.cs.iastate.edu/~leavens/JML/jmlrefman/jmlrefman_toc.html] .

Tool Support

There are a variety of tools that provide functionality based on JML annotations. The Iowa State JML tools provide an assertion checking compiler jmlc which converts JML annotations into runtime assertions, a documentation generator jmldoc which produces Javadoc documentation augmented with extra information from JML annotations, and a unit test generator jmlunit which generates JUnit testing frameworks from JML annotations.

In addition to the Iowa State JML tools a number of independent groups are working on tools that make use of JML annotations. These include:
* [http://secure.ucd.ie/products/opensource/ESCJava2/ ESC/Java2] , an extended static checker which uses JML annotations to perform more rigorous static checking than is otherwise possible;
* [http://pag.csail.mit.edu/daikon/ Daikon] , a dynamic invariant generator;
* KeY, which provides a theorem prover with a JML front-end;
* [http://www.lri.fr/~marche/krakatoa/ Krakatoa] , a theorem prover using the Coq proof assistant;
* [http://jmleclipse.projects.cis.ksu.edu/ JMLeclipse] , a plugin for the Eclipse integrated development environment with support for JML syntax and interfaces to various tools that make use of JML annotations.

References

* Gary T. Leavens, Yoonsik Cheon. Design by Contract with JML. Draft tutorial.
* Gary T. Leavens, Albert L. Baker, and Clyde Ruby. JML: A Notation for Detailed Design. In Haim Kilov, Bernhard Rumpe, and Ian Simmonds (editors), Behavioral Specifications of Businesses and Systems, chapter 12, pages 175-188. Kluwer, 1999.

External links

* [http://www.jmlspecs.org/ JML website]


Wikimedia Foundation. 2010.

Игры ⚽ Поможем сделать НИР

Look at other dictionaries:

  • Java Modeling Language — El Java Modeling Language, abreviado JML y en español «Lenguaje de Modelaje para Java» es un lenguaje de especificación para programas Java, que se sirve de pre , postcondiciones e invariantes de la lógica de Hoare, siguiendo el paradigma de… …   Wikipedia Español

  • Java Modeling Language — Le Java Modeling Language (JML) est un langage de spécification pour Java, il est basé sur le paradigme de la programmation par contrat. Il utilise la logique de Hoare, les pré et postconditions ainsi que les invariants. Les spécifications sont… …   Wikipédia en Français

  • Modeling language — A modeling language is any artificial language that can be used to express information or knowledge or systems in a structure that is defined by a consistent set of rules. The rules are used for interpretation of the meaning of components in the… …   Wikipedia

  • Unified Modeling Language — (UML) is a standardized general purpose modeling language in the field of software engineering. UML includes a set of graphical notation techniques to create abstract models of specific systems, referred to as UML model. Overview The Unified… …   Wikipedia

  • Unified Modeling Language — Die Unified Modeling Language (Vereinheitlichte Modellierungssprache), kurz UML, ist eine graphische Modellierungssprache zur Spezifikation, Konstruktion und Dokumentation von Software Teilen und anderen Systemen[1]. Sie wird von der Object… …   Deutsch Wikipedia

  • Unified Modeling Language — Pour les articles homonymes, voir UML. Logo d UML UML (en anglais Unified Modeling Language ou « langage de modélisation unifié ») est un langage de modélisation graphique à base de pictogrammes …   Wikipédia en Français

  • List of Unified Modeling Language tools — This article compares Unified Modeling Language tools. Contents 1 General 2 Features 3 Other UML tools 4 References …   Wikipedia

  • Virtual Reality Modeling Language — VRML im Programm dune (Version 0.13) Die Virtual Reality Modeling Language (VRML) ist eine Beschreibungssprache für 3D Szenen, deren Geometrien, Ausleuchtungen, Animationen und Interaktionsmöglichkeiten inklusive in der virtuellen Umgebung… …   Deutsch Wikipedia

  • Business Process Modeling Language — (BPML) is a meta language for the modeling of business processes, just as XML is a meta language for the modeling of business data. BPML was a proposed language, but now the BPMI has dropped support for this in favor of BPEL4WS. BPMI took this… …   Wikipedia

  • Rational Modeling Language — Ce langage est une abstraction et une modélisation de langage de programmation libre sous licence GNU General Public License, se basant sur la théorie des graphes et la théorie des groupes. Il utilise également les travaux réalisés par le… …   Wikipédia en Français

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”