Relational Aspects for Context Passing Beyond Stack Inspection
Rémi Douence, Obasco Group Emn-inria · 2006
In Java, context passing can be implemented by adding an argument to every method so that a value (i.e., context) is passed down the call stack to methods that require it. In AspectJ, context passing can be implemented by simply defining a pointcut with the cflow operator. In this article, we identify the essence of context passing in AspectJ, and generalize it beyond stack inspection. Our approach relies conceptually on databases and logic queries. When a method is called in the base program, it creates a relation between its receiver and its arguments. We use a logic language, Datalog, as a pointcut language in order to compose relations and pass context. This language has nice properties such as: queries always terminate, its fix point based semantics is declarative, recursion makes it expressive. A couple of Java examples, including a constraint solver and the JHotDraw GUI framework, illustrate the benefits of our relational aspects. 1. OVERVIEW Context passing is a natural application of AOP. Indeed, it requires to specify (at least) two points of interest. At one point context is collected. At the other point the collected context is accessed. In other words: context passing crosscuts the base program. For instance, AOP has been used to pass file opening mode to the prefetch module in an operating system [7], and to select top-level figures (by passing hierarchical context) to the refresh method in a graphical editor [2]. AspectJ [21] provides a pointcut language to define joinpoints (i.e., execution points) where an advice is to be executed. Basically, a pointcut specifies a method signature, but AspectJ also provides a pointcut construction cflow devoted to context passing. For instance, let us consider the following aspect Bill. 1 aspect Bill { 2 before(Caller c,Worker w):