Aspect-Oriented Programming (AOP) is used to express modular and orthogonal functionality in software components. The orthogonal functionality is programmed into an aspect, join points are used to describe where in the code the aspect should be inserted. Then the aspect is woven into the original program. Unlike compile time based strategies, dynamic AOP allows aspects to be woven at runtime. This has been shown to be very useful to adapt applications without interrupting service in a wide range of settings (business applications, wireless networks, robotics, etc.), thereby making dynamic AOP a prime candidate for supporting advanced, adaptive middleware platforms. A potential drawback of dynamic AOP is the performance overhead. In this paper, we tackle the performance problem by proposing a mechanism to implement dynamic AOP through method code replacement at runtime. The idea is to use the join points not to trigger the execution of the aspect (or advice) as it is done in most systems but to trigger the recompilation of the original code. The recompiled code contains the advice already woven into it or the callbacks to the corresponding advice, thereby greatly increasing the efficiency of the dynamic AOP process. In the paper we describe the technique, discuss extensive benchmarks to evaluate the performance gain of this approach, and compare the resulting system to other dynamic AOP approachesShow more