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

Karl Lieberherr, Northeastern University
David H. Lorenz, Northeastern University
Pengcheng Wu, Northeastern University

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.

In Proceedings of the 2nd International Conference on Aspect-Oriented Software Development, pages 40--49, Boston, Massachusetts, March 17-21, 2003. AOSD 2003, ACM.

aosd2003lod.ps.gz (52855k)

aosd2003lod.pdf (189103k)

Entry in the ACM Digital Library (1.06 MB)

The code from the paper:

Photos from the conference.

	Author = "Karl Lieberherr and David H. Lorenz and Pengcheng Wu",
	Crossref = "AOSD:2003",
	Pages = "40--49",
	Title = "A Case for Statically Executable Advice: {Checking} the {Law} of {Demeter} with {AspectJ}",
	URL = "http://www.ccs.neu.edu/home/lorenz/papers/aosd2003lod/",
	Year = 2003,
---------- AOSD crossref begin ----------
@String{PROC = "Proceedings of"}
@String{AOSD = "International Conference on Aspect-Oriented Software Development"}
@String{PROC:AOSD2003 = PROC#" the 2$^{nd}$ "#AOSD}
@String{AOSD2003 = "AOSD 2003"}
	Address = {Boston, Massachusetts},
	Booktitle = PROC:AOSD2003,
	Key = AOSD2003,
	Month = mar#{ 17-21},
	Organization = AOSD2003,
	Publisher = "{ACM}",
	Title = PROC:AOSD2003,
	Year = 2003,
---------- AOSD crossref end ----------