encyclopegia.org

Java Modeling Language

The Java Modeling Language (JML) is a specification language for Java programs, using Hoare style pre- and postconditions and invariants, that follows the design by contract paradigm. Specifications are written as Java annotation comments to the source files, which hence can be compiled with any Java compiler. Various verification tools, such as a runtime assertion checker and the Extended Static Checker (ESC/Java) aid development.

The Java Modeling Language (JML) is a specification language for Java programs, using Hoare style pre- and postconditions and invariants, that follows the design by contract paradigm. Specifications are written as Java annotation comments to the source files, which hence can be compiled with any Java compiler. Various verification tools, such as a runtime assertion checker and the Extended Static Checker (ESC/Java) aid development. //@ 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 postcondition for when a given Exception is thrown by the method that follows. signals_only : Defines what exceptions may be thrown when the given precondition holds. assignable : Defines which fields are allowed to be assigned to by the method that follows. pure : Declares a method to be side effect free (like assignable \nothing but can also throw exceptions). Furthermore, a pure method is supposed to always either terminate normally or throw an exception. invariant : Defines an invariant property of the class. loop_invariant : Defines a loop invariant for a loop. also : Combines specification cases and can also declare that a method is inheriting specifications from its supertypes. assert : Defines a JML assertion. spec_public : Declares a protected or private variable public for specification purposes. Basic JML also provides the following expressions \result : An identifier for the return value of the method that follows. \old( ) : A modifier to refer to the value of the at the time of entry into a method. (\forall ; ; ) : The universal quantifier. (\exists ; ; ) : The existential quantifier. a ==> b : a implies b a : a is implied by b a b : 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 and that have appropriate visibility. 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 /*@ spec_public @*/ int balance; private /*@ spec_public @*/ boolean isLocked = false; //@ public invariant balance >= 0 && balance Full documentation of JML syntax is available in the JML Reference Manual. Sireum/Kiasan, a symbolic execution based static analyzer which supports JML as a contract language. JMLUnit, a tool to generate files for running JUnit tests on JML annotated Java files. TACO, an open source program analysis tool that statically checks the compliance of a Java program against its Java Modeling Language specification. Marieke Huisman, Wolfgang Ahrendt, Daniel Bruns, and Martin Hentschel. Formal specification with JML. 2014. download (CC-BY-NC-ND)

References

No reference rows published for this article.

Cite this article

MLA

"Java Modeling Language." encyclopegia.org, 2026, https://encyclopegia.org/wiki/java-modeling-language. Accessed 24 November 2026.

Chicago

"Java Modeling Language." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/java-modeling-language.

APA

encyclopegia.org. (2026). Java Modeling Language. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/java-modeling-language

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Aberdeen Grammar School

enwiki · references available

Scottish baronial architecture

enwiki · references available

President of the Maldives

enwiki · references available

The Fighting Temeraire

enwiki · references available

Fraser McLuskey

enwiki · references available

Gustaaf Willem van Imhoff

enwiki · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1367513304 · 0.5 · snapshot enwiki-001367513304

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.