Cava library: query Java programs using SOUL

About Cava

Cava is a library of predicates for querying Java programs using SOUL. These predicates quantify over an abstract syntax tree representation of the program which stems from the Eclipse JDT Core Component. For each subclass of org.eclipse.jdt.core.dom.ASTNode, the library provides a unary predicate (e.g. isClassDeclaration/1) that quantifies over all AST nodes of this kind. Binary predicates (e.g. classDeclarationHasName:/2) quantify over the relations between each AST node and its children. In addition, the library provides higher-level predicates that quantify over relations between AST nodes that are not explicit in the AST representation. Examples include binary predicate isChildOf:/2 which quantifies over the relation between a node and its descendants or binary predicate inheritsFrom:/2 which quantifies over the inheritance relation between types.

Cava also defines a domain-specific unification procedure for AST nodes. Under this procedure, different AST nodes unify if they implement the same structural or behavioral characteristics. For instance, two expressions unify if they may evaluate to the same object at run-time. To this end, Cava consults the results of whole-program analyses obtained through the SOOT Java optimization framework. Finally, AST nodes unify with structurally equivalent compound terms. Instances of org.eclipse.jdt.core.dom.CastExpression, for instance, unify with compound terms of the form castExpression(?type,?expression) where ?type and ?expression are bound to the children of the CastExpression.

Authors

Coen De Roover and Johan Brichau

Documentation

For now, Chapter 5 of Coen De Roover's Phd thesis A Logic Meta Programming Foundation for Example-Driven Pattern Detection in Object-Oriented Programs describes Cava best. Chapter 6 describes the domain-specific unification procedure that comes with Cava.

Installing Cava

The latest version of Cava can be installed by loading the bundle named 'Soul-Cava' from our DMP store in a fresh Smalltalk image.

Dependencies

The following bundles will be loaded automatically from the DMP store as well:

  • JavaConnect enables invoking methods on Java objects from within Smalltalk
  • Penumbra enables accessing a headless Eclipse workspace from within Smalltalk
  • Soul the implementation of the SOUL program query language
  • Soul-JavaTemplates enables the use of template terms in SOUL queries
Related

The following libraries can be loaded manually to further enhance the functionality of Cava:

  • Soul-FuzzyLogic: provides the fuzzy variant of the SOUL program query language. A truth degree will be associated with the result for each query. These reflect the likelihood that a result is a false positive.
  • Soul-Barista: enables interacting with SOUL through an Eclipse plugin rather than the default Smalltalk tools.