A Case for Statically Executable Advice: Checking the Law of Demeter with AspectJ

Abstract

We define a generic join point model for checking the Law of Demeter (LoD). Join points are trees, pointcuts are predicates over join points, and advice is checked statically similar to how declare warning is checked in AspectJ. We illustrate how a joint point form is mapped to the object and class forms of LoD, and provide an implementation in AspectJ. The implementation approximates LoD’s class form by dynamically checking a particular execution using only the join points' static part. The paper proposes two ways to extend AspectJ to provide access to lexical join points directly. The first proposes statically executable advice and pointcuts in terms of lexical join points. The second proposes statically executable meta-advice over the exposed abstract syntax tree of the program and using Demeter style traversals to mirror AspectJ pointcuts.

Publication
AOSD'03
David H. Lorenz
David H. Lorenz
Dept. of Mathematics and Computer Science

Senior Faculty at Open University

Related