On-stack replacement (OSR) is a technique used by dynamic and adaptivecompilation systems to enable program specialization. Using OSR, anexecuting method can be recompiled (de- or re-optimized), and its runtime stackinvocation frame dynamically replaced with that of the new version, wheneverassumptions made for specialization are invalidated.Despite its potential, OSR is only used to a very limited degree in productionJava Virtual Machines (JVMs). Two reasons for this are the limited formsof OSR-based specializations available and the restrictions on compileroptimizations (and hence execution performance) imposed byextant OSR designs.In this paper, we address these limitations by extending anexisting JVM OSR implementation so that it is more amenable to optimization. Moreover, our OSR version can be used to implementaggressive specializations that are invalidated by events external to theexecuting code. We present a novel specialization forwrite-barrier avoidance for generational garbage collection (GC)using our system that reduces program startup time by 6%on average. We also evaluate our approach for specializationin a JVM that implements multiple GCs in a singlesystem and dynamically switches between them. Our OSRimplementation reduces the overhead of this system by 6% on average.Finally, we show that our system has the potential tosignificantly improve performance if used to avoid the checksthat guard speculatively inlined virtual method calls.We detail our OSR implementation and its empirical analysisin the open source Jikes Research Virtual Machine(JikesRVM) for Java from IBM Research.