OCLexec — Code generation from UML/OCL

OCLexec is a code generation tool that generates Java method bodies from UML/OCL specifications. OCL (Object Constraint Language) is a textual language extending UML.

OCLexec generates method bodies that conform to the postconditions of the corresponding OCL operation contracts and to any class invariants. The code generated uses a constraint solver to update the system state such that the postconditions and invariants are satisfied after every operation call. Objective functions and frame conditions that are specified in the UML profile of OCLexec can also be taken into account.


OCLexec is based on the OCLsolve library. See this API of OCLsolve for a description of the currently supported UML/OCL language features. Support for some features like Tuple types would have been feasible, but were not implemented due to lack of resources.

OCLexec processes XMI files (.uml) that are based on Eclipse UML2 3.x.

Since the runtime library includes some Linux x86 binary code, the execution of code generated with OCLexec may be more efficient on a Linux x86 system. However, the generated code is executable on any Java virtual machine.


The latest version of OCLexec can be downloaded here. See the README file in the distribution for instructions. 


These are some examples of UML/OCL specifications that OCLexec can process:




Matthias P. Krieger and Achim D. Brucker. Extending OCL Operation Contracts with Objective Functions. Proceedings of the International Workshop on OCL and Textual Modelling (OCL 2011). Electronic Communications of the EASST 44, 2011.

Matthias P. Krieger, Alexander Knapp and Burkhart Wolff. Automatic and Efficient Simulation of Operation Contracts. In E. Visser and J. Järvi, editors, Generative Programming and Component Engineering, pages 53–62. ACM, 2010.

Matthias P. Krieger and Alexander Knapp. Executing Underspecified OCL Operation Contracts with a SAT Solver. Proceedings of the 8th International Workshop on OCL Concepts and Tools (OCL 2008). Electronic Communications of the EASST 15, 2008.