Dynamic Aspect-Oriented Programming in Java: The HotWave Experience

Dynamic aspect-oriented programming (AOP) enables runtime adaptation of programs. It enables sophisticated, aspect-based software engineering tools, such as adaptive profilers or debuggers, which dynamically modify instrumentation code in response to user interactions. Today, many AOP frameworks for Java, notably AspectJ, focus on aspect weaving at build-time or at load-time, and offer only limited support for program adaptation by (re)weaving aspects at runtime. In this article, we present HotWave, an AOP framework based on AspectJ for standard Java Virtual Machines (JVMs). HotWave supports dynamic (re)weaving of previously loaded classes, and it ensures that all classes loaded in a JVM can be (re)woven, including the classes of the standard Java class library. HotWave features inter-advice communication, a mechanism that allows for efficient data passing between advice that are woven into the same method. We explain HotWave's programming model and discuss our implementation techniques. As a case study, we present an adaptive, aspect-based profiler that leverages HotWave's distinguishing features. A performance evaluation shows that HotWave does not introduce any overhead when no aspect is woven and explores the overhead of runtime weaving. While the duration of runtime weaving can be significant, the execution of woven code with HotWave does not incur any extra overhead when compared to the execution of code woven at build-time or at load-time.

[1]  Mikhail Dmitriev Profiling Java applications using code hotswapping and dynamic call graph revelation , 2004, WOSP '04.

[2]  Walter Binder,et al.  Comprehensive aspect weaving for Java , 2011, Sci. Comput. Program..

[3]  Walter Binder,et al.  Aspect weaving in standard Java class libraries , 2008, PPPJ '08.

[4]  Rainer Unland,et al.  Objects, Components, Architectures, Services, and Applications for a Networked World , 2003, Lecture Notes in Computer Science.

[5]  Gustavo Alonso,et al.  Dynamic weaving for aspect-oriented programming , 2002, AOSD '02.

[6]  Amer Diwan,et al.  The DaCapo benchmarks: java benchmarking development and analysis , 2006, OOPSLA '06.

[7]  David Holmes,et al.  Java Concurrency in Practice , 2006 .

[8]  James R. Larus,et al.  Exploiting hardware performance counters with flow and context sensitive profiling , 1997, PLDI '97.

[9]  Wim Vanderperren,et al.  Adaptive programming in JAsCo , 2005, AOSD '05.

[10]  Walter Binder,et al.  Visualizing and exploring profiles with calling context ring charts , 2010 .

[11]  Walter Binder,et al.  Rapid development of extensible profilers for the Java virtual machine with aspect-oriented programming , 2010, WOSP/SIPEW '10.

[12]  Walter Binder,et al.  Flexible and efficient measurement of dynamic bytecode metrics , 2006, GPCE '06.

[13]  Oscar Nierstrasz,et al.  Augmenting static source views in IDEs with dynamic metrics , 2009, 2009 IEEE International Conference on Software Maintenance.

[14]  Shigeru Chiba,et al.  Load-Time Structural Reflection in Java , 2000, ECOOP.

[15]  Alexandre Bergel FacetS: First Class Entities for an Open Dynamic AOP Language , 2006 .

[16]  Walter Binder,et al.  Platform-independent profiling in a virtual execution environment , 2009 .

[17]  Satoshi Matsuoka,et al.  ECOOP'97 — Object-Oriented Programming , 1997, Lecture Notes in Computer Science.

[18]  Walter Binder,et al.  Exploring large profiles with calling context ring charts , 2010, WOSP/SIPEW '10.

[19]  Walter Binder,et al.  Flexible calling context reification for aspect-oriented programming , 2009, AOSD '09.

[20]  William G. Griswold,et al.  An Overview of AspectJ , 2001, ECOOP.

[21]  Wim Vanderperren,et al.  JAsCo: an aspect-oriented approach tailored for component based software development , 2003, AOSD '03.

[22]  Hanspeter Mössenböck,et al.  Safe and atomic run-time code evolution for Java and its application to dynamic AOP , 2011, OOPSLA '11.

[23]  Walter Binder,et al.  Visualizing Calling Context profiles with Ring Charts , 2009, 2009 5th IEEE International Workshop on Visualizing Software for Understanding and Analysis.

[24]  Walter Binder,et al.  Polymorphic bytecode instrumentation , 2011, AOSD '11.

[25]  Oscar Nierstrasz,et al.  Senseo: Enriching Eclipse's static source views with dynamic metrics , 2009, 2009 IEEE International Conference on Software Maintenance.

[26]  Laurence Duchien,et al.  JAC: an aspect‐based distributed dynamic framework , 2004, Softw. Pract. Exp..

[27]  Gustavo Alonso,et al.  Controlled, systematic, and efficient code replacement for running java programs , 2008, Eurosys '08.

[28]  Walter Binder,et al.  HotWave: creating adaptive tools with dynamic aspect-oriented programming in Java , 2009, GPCE '09.

[29]  Walter Binder,et al.  Advanced runtime adaptation for Java , 2009, GPCE '09.

[30]  Walter Binder,et al.  Flexible and efficient profiling with aspect‐oriented programming , 2011, Concurr. Comput. Pract. Exp..

[31]  Ondrej Lhoták,et al.  abc: an extensible AspectJ compiler , 2005, AOSD '05.

[32]  Frank Yellin,et al.  The Java Virtual Machine Specification , 1996 .

[33]  Paul H. J. Kelly,et al.  Profiling with AspectJ , 2007 .

[34]  Stephen J. Fink,et al.  The Jalapeño virtual machine , 2000, IBM Syst. J..

[35]  Michael Haupt,et al.  Virtual machine support for dynamic join points , 2004, AOSD '04.

[36]  James Gosling,et al.  The Java Language Specification, 3rd Edition , 2005 .

[37]  Guy L. Steele,et al.  Java(TM) Language Specification, The (3rd Edition) (Java (Addison-Wesley)) , 2005 .

[38]  Elisa Bertino,et al.  ECOOP 2000 — Object-Oriented Programming , 2000, Lecture Notes in Computer Science.

[39]  Walter Binder,et al.  Advanced Java bytecode instrumentation , 2007, PPPJ.

[40]  Walter Binder,et al.  CCCP: complete calling context profiling in virtual execution environments , 2009, PEPM '09.

[41]  Oscar Nierstrasz,et al.  Exploiting Dynamic Information in IDEs Improves Speed and Correctness of Software Maintenance Tasks , 2012, IEEE Transactions on Software Engineering.

[42]  Michael Eichberg,et al.  An execution layer for aspect-oriented programming languages , 2005, VEE '05.

[43]  Gustavo Alonso,et al.  Just-in-time aspects: efficient dynamic weaving for Java , 2003, AOSD '03.

[44]  Jørgen Lindskov Knudsen ECOOP 2001 — Object-Oriented Programming , 2001, Lecture Notes in Computer Science.

[45]  Gregor Kiczales,et al.  Aspect-oriented programming , 1996, CSUR.

[46]  Jeremy Manson,et al.  The Java memory model , 2005, POPL '05.

[47]  Luis Daniel Benavides Navarro,et al.  Debugging and Testing Middleware with Aspect-Based Control-Flow and Causal Patterns , 2008, Middleware.

[48]  Gustavo Alonso,et al.  Making Applications Persistent at Run-time , 2007, 2007 IEEE 23rd International Conference on Data Engineering.

[49]  Jim Hugunin,et al.  Advice weaving in AspectJ , 2004, AOSD '04.

[50]  Michiaki Tatsubori,et al.  Using HotSwap for Implementing Dynamic AOP Systems , 2003 .

[51]  D. B. Davis,et al.  Sun Microsystems Inc. , 1993 .

[52]  Robert Hirschfeld,et al.  AspectS - Aspect-Oriented Programming with Squeak , 2002, NetObjectDays.

[53]  Jong-Deok Choi,et al.  Accurate, efficient, and adaptive calling context profiling , 2006, PLDI '06.