Home

JML

JML, the Java Modeling Language, is a behavioral specification language for Java that enables programmers to state contracts for Java methods and classes without altering Java syntax. It allows preconditions, postconditions, invariants, and frame conditions to be expressed as part of the source.

Specifications are written in Java comments, using constructs such as requires, ensures, invariant, and assignable. For

JML specifications can be checked at runtime or by static analysis. Runtime assertion checking inserts checks

JML originated in the late 1990s as part of research into formal methods for object-oriented software. It

JML is not part of the Java language specification; it is a separate language that complements Java

example,
a
method
that
returns
a
non-negative
result
might
declare
ensures
\result
>=
0,
and
a
state-changing
method
may
specify
an
assignable
clause.
JML
also
supports
model
fields,
ghost
variables,
and
quantifiers
for
expressing
abstract
properties.
during
execution;
static
verifiers
attempt
to
prove
that
Java
code
conforms
to
its
JML
specification.
Tools
include
ESC/Java2,
Krakatoa
(historical),
and
OpenJML,
which
integrates
with
the
Java
toolchain
and
IDEs.
is
widely
used
in
academia
and
has
influenced
approaches
to
specification-driven
development.
Open-source
OpenJML
remains
a
primary
implementation
for
verification
and
testing.
by
providing
a
formal
contract
framework.
It
is
intended
to
improve
program
reliability
and
facilitate
verification
and
documentation
of
Java
code.