Now available: Clara, a novel framework for implementing hybrid typestate analyses

Eric | September 10, 2009

ClaraIn my doctoral dissertation (click here for a draft), I present Clara (Compile-time Approximation of Runtime Analyses), a novel research framework for the implementation of hybrid typestate analyses. Clara is now online – fully documented – at: http://www.bodden.de/clara/

Typestate properties aid program understanding, and one can even define type systems that prevent programmers from causing typestate errors, or derive static typestate analyses that try to determine whether a given program violates typestate properties. Unfortunately, the typestate-analysis problem is generally undecidable. Researchers have therefore proposed a hybrid approach that uses
static-analysis results to generate a residual runtime monitor. This monitor captures actual property violations as they occur, but only updates its internal state at relevant statements, as determined through static analysis.

Clara allows researchers to implement such hybrid typestate analyses with a minimal amount of code.

For Researchers, Clara offers:

For Developers, Clara offers:

We wish to extend Clara in the future. Please join our mailing list if you want to stay tuned on further developments. Or, if you even feel like extending Clara with your own analyses, download the tool and, if you feel like it, drop us a line.

    Details about the Clara framework

    Overview of Clara Clara’s major design goal is to de-couple the code-generation for efficient runtime monitors from the static analyses that convert these monitors into faster, residual monitors. The figure to the right gives an overview of Clara. With Clara, the researcher first defines a set of typestate properties, denoting each property as an annotation to an AspectJ aspect that implements a runtime monitor for the same property. Annotations directly encode a non-deterministic finite-state machine. In my dissertation, I show how researchers can even use runtime- monitoring approaches like tracematches, JavaMOP, and others, to generate these annotated aspects automatically from high-level monitor specifications.

    Clara weaves the monitoring aspect into the program under test and emits helper classes that implement the run- time monitor as defined by the aspect. Clara extends the  AspectBench Compiler for this purpose. Clara then invokes its static-typestate-analysis engine. Researchers can add a number of static analyses to Clara and have them applied in any order. These analyses obtain, through the finite-state machine defined in the aspect’s annotation, enough in- formation about the typestate property to precisely approximate the set of relevant instrumentation points. When an analysis determines that an instrumentation point is irrelevant to a property, i.e., the program can neither violate the property nor prevent a property violation at this point, then Clara automatically disables the instrumentation for this property at this point. The result is an optimized instrumented program that updates the runtime monitor only at program points at which instrumentation remains enabled.

    Clara originated as Eric Bodden‘s doctoral-thesis project at the Sable Research Group. The design and implementation of Clara was greatly influenced by the work of this group and the Programming Tools Group at the University of Oxford, specifically Laurie Hendren, Patrick Lam, Oege de Moor, Pavel Avgustinov and Julian Tibble. Clara uses technogies from the AspectBench Compiler, Soot, JastAdd, polyglot and other open-source projects.