Redefining a Class While Debugging

While debugging, use the HotSwap feature to fix errors and substitute corrected class definitions, without stopping and restarting your application. HotSwap is an enhancement to the Java Platform Debugger Architecture (JPDA) in Java 2 SDK v1.4, and has been implemented in JDeveloper's Java virtual machine, OJVM.

When the debugger is paused you can recompile classes. When the debugger resumes after code has been HotSwapped, threads that are currently executing old method definitions will continue to do so until those methods return. For subsequent method calls, the class definition will be used. However, existing instances of the class will not be modified, and class variables will not be reset. Use HotSwap to modify the logic of class methods. In most cases you cannot use HotSwap to make more substantial changes, such as adding or removing fields or methods.

To redefine a class while debugging:

  1. Edit the class' source code.

  2. Recompile the class: From the main menu, choose Run then choose Make <classname>, or right-click in the source editor and choose Make.

    A message is shown in the debugger's log window, stating that the redefinition has been successful, or not.

  3. Click resume_icon in the debugger toolbar to resume execution.

    Threads that are currently executing old method definitions will continue to do so until those methods return. For subsequent method calls execution resumes using the new class definition..


Debugging a Program
Popping Frames from the Execution Stack