JML Eclipse Plug-in

Author: David R. Cok
April 2026
Feedback

This plug-in provides JML functionality integrated with the Eclipse (2025-06 and later) UI for Java 21 and OpenJML 21.0.25. It is a GUI interface to the OpenJML command-line tool, operating through an LSP server for OpenJML.

A language reference for JML is here.

A User Guide for the OpenJML tool is here.

A tutorial for JML/OpenJML is here.

An integration Guide to aid in connecting the OpenJML language server to LSP clients (in general, but including Eclipse) is here.

Because OpenJML is built on OpenJDK, this LSP-compliant server is also an LSP interface for OpenJDK.

Contents:

Overview

This plug-in provides Java Modeling Language (JML) functionality as an Eclipse plug-in into the Java development environment of Eclipse using an LSP server that is part of the openjml tool. The JML plug-in in particular provides functionality for checking and manipulating formal specifications of Java programs. The plug-in is tested with 2025-06; the back-end OpenJML tool supports Java version OpenJDK 21 (openjml version 21.0.25 and following).

The command-line OpenJML tool, which is needed to use this Eclipse plug-in, can be found here.

Licensing: The plug-in builds on the Eclipse JDT and PDE, through their public interfaces; it does not modify or contribute to Eclipse itself. The source for the plug-in is available at the OpenJML github project. This version of the plug-in is offered without cost and without warranty of any kind. Feedback that will improve its usefulness is welcome. This version of the plug-in is distributed under the Eclipse Public License. The copyright is retained by the primary author. Future versions may use other licenses. The underlying OpenJML tool is built on OpenJDK (OpenJDK is a trademark of Oracle). OpenJDK and thus OpenJML is licensed under GPL. The language server for OpenJML uses the lsp4j library; it uses the lsp4e library to connect to Eclipse.

The plug-in adds the following functionality to Eclipse's Java Perspective:

Installation

The plug-in is installed, updated, and uninstalled from Eclipse in the standard way. The update site containing the plug-in is https://openjml.org/eclipse-update-site. Eclipse requires that Eclipse itself be restarted after installing a new plug-in like this one.

The plug-in needs an installation of OpenJML to operate. The current release for your platform can be obtained here.

Once installed, the path to that installation must be entered on the plug-in's Eclipse Settings/Preferences page for OpenJML. Also projects must be given a 'JML Nature' in order for OpenJML actions to apply to them (a menu command will add this Nature).

OpenJML Actions

The plug-in offers buttons and menu items to accomplish some OpenJML actions. Note that the class-, source-, and specs- patahs used by OpenJML actions are decribed in the Preferences section.

Selection

OpenJML actions act on the items selected.

Syntax and type-checking

The OpenJML plug-in expands on Eclipse's usual as-you-edit programming-language (e.g., Java) syntax and type checking to provide checking of JML text in JML comments and .jml files. Such checking of JML text can be performed at various times, controlled by a setting in the OpenJML Preferences ("JML type-check trigger").

Static checking of JML assertions

Performing deductive verification (ESC) on selected items is typically triggered manually because it can be time-consuming and is performed asynchronously. There is a Preference that allows triggering ESC automatically on a file at file save. One can always trigger ESC manually on whatever Java elements are selected by pressing the toolbar icon, the menu item under the top-level 'OpenJML' menu, or a context menu item. A setting allows choosing whether edited files are automatically saved, or not, when ESC is invoked. If edited files are not saved, the ESC operation acts on the content of the editor. It is also possible to initiate an ESC verification on a single method.

Results of proof attempts on each method are reported in the Console and as code lens information associated with the method definition.

ESC operations are always separated by project, since projects may have different class- and sourcepaths. Within a given project, ESC operations on one or more items can be launched as a single ESC check in OpenJML, divided up by file, or divided up by individual method. Finer division allows more concurrency, but requires more overhead per ESC operation. If individual methods are selected in one of the Views, proofs of those methods are always separate, stand-alone tasks.

ESC operations can be cancelled or retried -- see the cancel and code lens information.

Canceling ESC tasks

The ESC tasks started by one of the 'Run ESC' commands can be cancelled by the 'Cancel ESC' command (which is a menu command). This command shows a dialog that lists the ESC tasks that are running, giving the user the opporutnity to choose which tasks should be cancelled. Although each task emits its method proof results as the methods are proved, each task runs through all its method sequentially. Cancelling a task aborts any in-progress proof and halts attempting any further proofs.

An alternative way to cancel a proof is to use the Cancel button in a code lens, shown by a method being proved. Selecting this cancel button aborts only the in-progress proof attempt.

Compiling for Runtime-assertion checking (RAC)

The RAC command compiles selected files with JML assertions. At present this action must be done manually on selected items after an Eclipse compilation is complete. The RAC-compiled class files overwrite any Java-compiled files, and they are also overwritten in turn by Java-compiled files on the next Java compilation. Java compilations can happen automatically on file saves. RAC commands always operate only on the saved content of files, as Java compilations do.

Add/Remove OpenJML Nature

OpenJML plug-in commands act only on projects or items in projects that have a JML nature. This allows a user to stipulate for which Java projects JML actions should be enabled. These two commands add or remove the JML Nature from selected projects, or the projects containing selected items. Note that removing the JML Nature from a project also removes all OpenJML error and warning markers from files in that project.

Clear Markers

These two operations remove OpenJML markers from the workspace. Both operations are useful when markers are stale or obsolete and will not otherwise clear.

Index Project

This operation manually initiates typechecking of all files in the selected project (whether open in editors or not), initializing the index of declarations and ASTs.

Clear and Reindex

This operation is roughly equivalent to quitting and restarting the plug-in -- all markers are deleted, all cached information is deleted and, if needed, is regenerated. The operation is intended just if it seems internal information has gotten out of synch with the files themselves.

Standard LSP interactions implemented for OpenJML

Problem markers

The plug-in implements its own set of problem markers, using the LSP mechanism for reporting problems. JML Markers identify JML syntax and type errors and warnings and informational messages. ESC Markers identify JML Verification failures (as errors) and associated information (as warnings) and verification success (as informational, green markers). The style and coloring of these markers can be set in the General >> Editors >> Text Editors >> Annotations settings.

Syntax coloring

The server reports token types (for parsable source files), enabling clients to render files with syntax coloring. The server reports all relevant token types that LSP defines. The rendering of syntax color and style is completely up to the client. In the case of Eclipse there is a conflict between JDT renderings for Java text and renderings through the LSP library. To simplify using color preferences, the OpenJML plug-in defines its own set of preferences on an OpenJML Preferences tab; these override colors defined by other mechanisms. The OpenJML Settings includes an option to defer to JDT coloring on Java text.

Find Declaration

The standard Java 'Find Declaration' action applies only to Java code and cannot be overridden to apply also to JML text. The plug-in implements its own Find Declaration action (under OpenJML >> Find Declaration); this action operates much like the Java action but also finds declarations for instances of variables in JML text, whether those declarations are Java or JML declarations. The action will implicitly do a full project check if needed. Declarations are only found within a project.

Find References

The standard Java 'Find References' action applies only to Java code and cannot be overridden to apply also to JML text. The plug-in implements its own Find References action (under OpenJML >> Find References); this action operates much like the Java action but also finds references for instances of variables in JML text, whether the uses or declarations are in Java or JML program text. The action will implicitly do a full project check if needed, in order to be able to find all references consistently. References are only found within a project.

Rename

The standard Java 'Rename' refactoring action applies only to Java code and cannot be overridden to apply also to JML text. The plug-in implements its own renaming action (under OpenJML >> Rename); this action operates much like the Java rename but renames the corresponding identifiers in JML text also. The action will implicitly do a full project check if needed, in order to be able to find all references consistently. References are only renamed within a project.

Find all declarations

This action finds all the declarations of a given identifier within a selected project.

Folding

The OpenJML LSP declares some folding regions that an LSP client will display and allow the user (in an editor) to fold up a sequence of lines of code. Java already does this for method and class bodies. OpenJML adds folding for a consecutive sequence of JML annotations and Java comments with no embedded non-JML non-comment text, other than whitespace.

Outline

The JDT shows a tree-structured view of the declarations and enclosing classes of a .java file. The plug-in provides similar information for a .jml file. What is currently lacking is a consolidated outline holding both java and JML information (because of conflicts between the JDT and the LSP implementation in Eclipse).

Code Lens information

Code Lens information is shown in conjunction with a method declaration. The code lens information contains the most recent proof (ESC) attempt for that method: either unknown (-), checking, verified (check mark), or not verified (x). Editing the method does not change these "last attempt" results.

Clicking on the code lens will cancel a current proof attempt on that method, if a proof is in progress, or otherwise initiate a retry of the proof.

Hover and inlay information

As hover or inlay information, the plug-in shows the type of a local variable declared with 'var' or the specifications of a method.

Completions

The plug-in shows possible completions of JML identifiers in JML text, specifically JML keywords (e.g., requires) and JML backslash keywords (e.g. \forall).

Signature Help

When there is a partially-typed method call (in JML text), the plug-in shows a method signature to aid in completing This is standard LSP signature-help functionality.

Currently this functionality is a bit limited: it only shows one of the potential signatures and only selects one from the same file; no type information from the receiver is used.

Eclipse functionality adapted to OpenJML

Content type and Icon

The plug-in defines a content type for .jml files. This content type is associated with the JML icon, so the icon marks editors and files that have this content type. The content type is also associated with the "Generic Code Editor". This editor is used rather than a Java editor for .jml files because a Java editor would mark as errors those ways in which a .jml file differs from a .java file.

OpenJML Preferences

The plug-in implements a standard Eclipse Preferences (or Settings) page, with four tabs: Plug-in and LSP Settings, Syntax Colors, OpenJML Tool Options. and Project Options. The options control aspects of the plug-in itself and the LSP server, the color preferences for syntax coloring, and the underlying OpenJML tool, respectively. The OpenJML Tool Options correspond to the command-line options of the command-line `openjml` tool; all the non-default OpenJML tool options are sent to OpenJML whenever an OpenJML action is requested.

Paths

The Project Options tab holds path settings that influence what is communicated to OpenJML. These fields act as user additions prepended to the paths that Eclipse assembles from its own project model:

All three paths are project-specific. Path entries must be separated by the OS path-separator character (colon on macOS/Linux, semicolon on Windows). Path values may contain environment-variable references of the form $VARNAME, ${VARNAME}, or $(VARNAME); the server substitutes the variable's value from the execution environment before passing the result to OpenJML.

Two output directory settings govern where compiled .class files are written and found:

A Help page

The plug-in implements a standard Eclipse Help page to give user guide style information about the Eclipse Plug-in.

Other Eclipse functionality

Nothing special is implemented with the following functionality, but it is available to users of the plug-in to improve their own experience with Eclipse.

Some OpenJML plug-in infelicities and troubleshooting