Aspect-oriented programming and design
Avoiding infinite recursion with Stratified Aspects
Infinite recursion is a known problem of aspect-oriented programming with AspectJ: if no special precautions are taken, aspects which advise other aspects can easily and unintentionally advise themselves. We developed a compiler for an extension of the AspectJ programming language that avoids self reference by associating aspects with levels, and by automatically restricting the scope of pointcuts used by an aspect to joinpoints of lower levels. We report on a case study using our language extension and quantify the changes necessary for migrating existing applications to it. Our results suggest that we can make programming with AspectJ simpler and safer, without restricting its expressive power unduly.
Read more about this research on the related web site.
Relational aspects as tracematches (and “relational tracematches”)
The relationships between objects in object-oriented applications are an essential property of the program’s design and implementation. Two previous approaches to implement relationships with aspects were association aspects, an AspectJ-based language extension, and the relationship aspects library. While those approaches greatly ease software development, we believe that they are not general enough. For instance, the library approach only works for binary relations, while the language extension does not allow for the association of primitive values or values from non-weavable classes.
Hence, in our work we proposed a generalized alternative implementation via a direct reduction to tracematches, a language feature for executing an advice after having matched a sequence of events.
This new implementation scheme yields multiple benefits. Firstly, our implementation is more general than existing ones, avoiding most previous limitations. It also yields a new language construct, relational tracematches.
We provide an efficient implementation based on the AspectBench compiler, along with test cases and micro-benchmarks. Our empirical studies showed that our implementation, when compared to previous approaches, uses a similar memory footprint with no leaking, but the generality of our approach does lead to some runtime overhead. We believe that our implementation can provide a solid foundation for future research.
The following code snippet shows a relational aspect in action.
relational abstract aspect SimpleObserver(Subject s, Observer o) {
abstract pointcut subjectChanged(Subject subj);
relational after(): subjectChanged(s) {
o. notify(s );
}
}
This aspect implements the well-known Observer pattern in which a set of observers is to be notified about certain observable changes in the state of a particular subject. With this aspect, all the client code has to do is call:
SimpleObserver.associate(mySubject,myObserver);
This will then automatically register this pair of objects with the aspect. Then, whenever the subject is updated, the after-advice in the relational aspect is executed. Conversely, the advice will not execute if a subject is updated that was not registered with the aspect. Hence, relational aspects can be used to attach semantics to groups of objects, implementing collaborations in a modular way.
Download the full AOSD 2008 paper here.
An AspectJ library for fault tolerance
As a course project at McGill, I developed a little library for fault tolerance, written in AspectJ 5. It contains two components:
- Support for automatic N-Version programming.
- A full implementation of a recovery cache.
More information about this project can be found here.






[...] you could just as well have used association aspects or the relational aspects we proposed for next year’s AOSD conference. Using a relational aspect you can just implement [...]