Analysis of Aspect Oriented Programs


The objective of this project is to provide tool support for programmers using aspect-oriented languages, based on dynamic and static program analysis.

Programmers shall be enabled to check the influence of their aspects on the base system as well as on other aspects. The benefit of this calculated information is obvious: programmers could use the analysis results to better understand the interactions of defined aspects among each other as well as the interactions of aspects ans base system. This information is necessary to avoid introducing flaws into a program up front or find the reasons for occurring problems.

First results

Analysis of potential pitfalls for AspectJ programmers

Aspect-oriented programming (and AspectJ in particular) offers a broad set of language elements which unfortunately can also result in code hard to understand or which even can introduce very subtle flaws into a program.

Program Analysis is increasingly used to enhance program understanding and find flaws in programs. In contrast to testing, it can guarantee properties of a program. Up to now, in the context of program analysis, aspect oriented programming (AOP) has mostly been used for program instrumentation (tracing), but has not been itself subject to analytical methods.

The starting point of our work identifies sources of flaws in AOP and suggests that program analysis could be used to avoid these pitfalls. The subject of the resulting paper (see below) is not to present any solution for identified problems, but presents ideas how a solution might be approached.

Analytical problems and AspectJ

Checking the effects of static program modifications

AspectJ currently is the most important general purpose AO language implementing aspect-oriented programming on top of Java. Besides modification of program flow and state using advice, AspectJ offers language elements to statically modify existing classes by changing their position in the inheritance hierarchy or introducing new members.

As also stated in our first paper, this can lead to binding interference, i.e. the dynamic lookup of method calls not affected directly by the aspect might change.

Based on prior work of Frank Tip and Gregor Snelting, we developed methods allowing programmers to automatically check the impact of introductions and hierarchy modifications on existing programs.

A first prototypic implementation of these methods has been done, but we currently try to incorporate this analysis in our AJ analysis infrastructure and no longer maintain the prototype.

Interference Analysis for AspectJ

Detecting changed program semantics using Trace Analysis

Aspect-languages in general are designed to change some `aspects' of system behavior. However, to test these changes can be problematic, as aspect application might influence not only observable behavior but also can change program flow internally.

To test if an aspect works as intended, we suggest trace analysis to capture these internal changes. We demonstrate how trace analysis can be used for impact analysis. It can also be used to validate that refactorings which replaced scattered code by an aspect did not change system behavior.

Trace Analysis for Aspect Application

Attacking the fragile pointcut problem: Pointcut deltas

Aspect oriented programming has been proposed as a way to improve modularity of software systems by allowing encapsulation of crosscutting concerns. To do so, aspects specify where new functionality should apply using pointcuts.

Unfortunately todays mainstream aspect oriented languages suffer from pointcut languages where pointcut declarations result in a high coupling between aspect and base system. Additionally, these pointcuts are fragile, as non-local changes easily may break pointcut semantics.

We are currently implementing an analysis to compare pointcut matches for two different version of AspectJ programs. The resulting delta is presented to the programmer in using the IDE Eclipse.

PCDiff: Attacking the Fragile Pointcut Problem

Current projects

Unfortunately an overview of current projects is currently only available in German. Please give us some time to translate this into English.

Pointcut languages (master thesis): towards declarative joinpoints

AspectJ erlaubt es Programmierern, die Funktionalität vorhandener Klassen durch advice zu modifizieren. Dazu muss einerseits die neue Funktionalität ähnlich einer Java Methode implementiert werden (advice), andererseits muss auch spezifiziert werden, wo diese neue Methode ausgeführt wird. Hierzu werden so genannte pointcuts definiert.

Ziel sollte es nun sein, dass diese pointcuts möglichst deklarativ und mit möglichst wenigen expliziten Referenzen zum Zielsystem definiert werden können.

Im Rahmen einer Diplomarbeit wird derzeit ein neuer Pointcut entwickelt, der es Programmierern erlaubt z.B. für das Observer Pattern das Observer-Protokoll deklarativ zu spezifizieren. Wir nennen die resultierende Sprache AJ+.

Als Ergebnis der Arbeit soll ein Cross-Compiler AJ+-Quellcode in legalen AspectJ-Code übersetzen.

Dynamic change impact analysis for AspectJ (master thesis)

Basierend auf der Arbeit von Barbara Ryder und Frank Tip zum Thema `Object-Oriented Change Impact Analysis' wird derzeit im Rahmen einer Diplomarbeit ein Framework für die (dynamische) Analyse von aspekt-orientierten Programmen entwickelt, mit dessen Hilfe die Auswirkungen der Anwendung von Aspekten auf die Semantik des Systems ermittelt werden können.

Analog zur objekt-orientierten Variante soll dabei die Analyse anhand des Callgraphen erfolgen. In dieser Arbeit wird dabei hauptsächlich ein dynamischer Analyse-Ansatz verfolgt, wobei aber auch ein Vergleich mit einem zugrundeliegenden statischen Callgraphen geplant ist.

Checking orthogonality for AspectJ-aspects (joint bachelor project)

Im Rahmen von zwei Bachelor-Arbeiten wird derzeit eine Analyse für den Nachweis der Kontrollfluss-Erhaltung implementiert. Insbesondere sind mögliche Änderungen von Kontroll- und Datenfluss in Hinblick auf Exceptions und around-advice Ziel der Analyse.

Da dieses Problem bekanntlich im Allgemeinen unentscheidbar ist (Halteproblem), werden in einem ersten Schritt geeignete vereinfachende Annahmen herangezogen werden, z.B. dass die vom Aspekt aus aufgerufene Funktionalität des Basissystems immer terminiert, dass keine/nur deklarierte Exceptions geworfen werden, usw. Diese Annahmen sollen im Verlauf der Arbeit soweit möglich reduziert werden bzw. durch prüfbare Kriterien ersetzt werden.

Natürlich ist für den Kontrollfluss auch die Erhaltung des Datenflusses relevant, und andersherum. Man denke nur an dynamische Bindung (Austausch von Parameter-Objekt durch Subklassenobjekt) oder if-Verzweigungen. Insofern sind beide Bachelor-Projekte ineinander verzahnt.

Analysis Infrastructure for a core aspect-oriented language (AJ)

The base for any program analysis is an infrastructure allowing to transform source code in more structured representation which is more suitable for analysis - the abstract syntax tree, short AST.

Although this is an important step, it is only a starting point for program analysis. As we want to analyze source code, we first have to solve a bunch of problems which do not occur when dealing with byte code, for example name resolution.

Our infrastructure is able to parse a restricted object-oriented aspect-language called AJ, which is a subset of AspectJ. We plan to extend this language to add all important features of AspectJ as this project goes along.

Please note that this infrastructure currently is a pure research prototype and thus no stable software available for distribution. This might change some day.


  • AST construction for AJ, including typing and name resolution.
  • Created a high-level hierarchy access.
  • Callgraph construction including aspect wrapper hierarchies and dynamic binding.

Current restrictions:

  • No nested types
  • Only a limited pointcut model (extension in progress)
  • Only restricted evaluation of modifiers (extension in progress)
  • Currently only a rather simple type analysis (CHA)

Next enhancements

Current efforts on further infrastructure developments are threefold:

  • Increase the number of recognized language constructs, especially add interfaces, exceptions and more pointcut designators.
  • Improve the type analysis.

We expect our analysis infrastructure to be capable to cope with a considerably increased amount of language elements by the end og this year. The infrastructure and any analysis using it are implemented as Eclipse-plugins.


M. Störzer, B. Ryder, X. Ren, F. Tip: Finding Failure Inducing Changes in Java Programs using Change Classification. FSE 2006
M. Störzer, U. Eibauer, S. Schöffmann: Aspect Mining for Aspect Refactoring: An Experience Report. TEAM 2006
M. Störzer, F. Forster, R. Sterr: Detecting Precedence-Related Advice Interference. ASE 2006
M. Störzer, S. Hanenberg: A Classification of Pointcut Language Constructs. SPLAT 2005
M. Störzer, J. Graf: Using Pointcut Delta Analysis to Support Evolution of Aspect-Oriented Software. ICSM 2005
C. Constantinides, T. Skotiniotis, M. Störzer: AOP Considered Harmful. EIWAS 2004
M. Störzer, C. Koppen: PCDiff: Attacking the Fragile Pointcut Problem, Abstract. EIWAS 2004
M. Störzer, J. Krinke, S. Breu: Trace Analysis for Aspect Application. AAOS 2003
M. Störzer: Analysis of AspectJ Programs. GIAOSD 2003
M. Störzer, J. Krinke: Interference Analysis for AspectJ. FOAL 2003