Enhance the class redefinition capabilities of the HotSpot VM to support, at runtime, the addition of supertypes and the addition and removal of methods and fields.
Introduction of additional API in JVMTI, JDWP, JDI or the
java.lang.instrument package is not a goal. The new mechanism will be
accessed using the existing class redefinition interfaces.
The current class redefinition capabilities only allow the swapping of method bodies, which is a severe restriction. The proposed feature relaxes the restriction and improves the productivity of Java programmers during development of an application by removing the need to restart an application after changes. The benefit is particularly high when developing on an application server or for applications with long startup times.
The proposed feature enhances the implementation of the JVMTI class redefinition functionality in the HotSpot VM. It does not modify any Java APIs or library/JVM interfaces.
In particular the proposed enhancement to class redefinition includes the ability to modify classes at run time by:
- Adding/removing methods
- Adding/removing static and instance fields
- Adding supertypes
The behavior of the current mechanism that swaps method bodies is unaffected. Removing supertypes from a class remains prohibited.
Adding or removing instance fields affects all existing instances of a
class. Newly inserted fields are initialized with 0, null or false
according to their type. Calling a method after it was deleted or
accessing a field after it was deleted results in a
There are several publications about the technical details of the proposed implementation:
Additionally, there is an existing prototype, the Dynamic Code Evolution VM, that fully supports the proposed features and can be downloaded in source and binary form.
In addition to the current class redefinition tests, there need to be new tests for the enhanced functionality (i.e., tests that add/remove fields and methods and add supertypes).
This proposal only impacts the implementation of the HotSpot VM and does
not impact other JDK components. There is a small impact on the API
documentation for the class redefinition functionality in JVMTI, JDWP,
JDI, and the