Java Reference
In-Depth Information
Watched values are displayed in the watch view just as they are in the inspec-
tion window, and they're fully navigable. Expressions that can't be evaluated in
the current context are displayed with question marks as the result.
You can add items to your watch list two ways. From the Frame tab, inspection
window, or Expression Evaluator window, right-click an item and select Add to
Wa tc h e s . You can even add new watches while the debugger isn't running, by
selecting items in the editor and calling Add to Watches from the context menu
(they won't evaluate to anything until the debugger is running).
To remove a watch-list item, right-click the item and select Remote Watch or
Remove All Watches . Alternatively, select the watch and click the Delete key. The
right-click menu also provides an Edit Watch option that lets you change the
expression represented by the watch list item.
6.4.4
Altering your program while debugging
The IDEA debugger has one more interesting feature worth noting: the ability to
modify the running code in order to observe the resulting behavior, eliminating
the need for recompiling the source code to test every theory.
Changing the runtime value of variables and fields
In the Frame view of the Debug window, right-click an item and select the Set
Va l u e option from the context menu. A text field appears in the Frame tab next
to the desired item, so you can enter the new value. The value is now changed and
will affect the program when you resume execution or continue stepping through
the code. Note that you can only set primitive values and String s using this fea-
ture. To remove the text field from the Frame tab, select the text field and press
the Esc key.
Hot swapping classes to test your fixes without leaving the debugger
One of the most powerful new features of the debugger in IDEA is support for
swapping in new versions of classes while the program is running. This feature
only works with applications running under JDK 1.4 or newer. To use the hot-
swap feature during your debugging session, modify and recompile the classes
you wish to swap in. If the debugger is running, IDEA suggests automatically
reloading the changed classes, or it reloads them silently, depending on your cur-
rent Debugger settings (described in the next section). Another way is to perform
necessary modifications in your code and execute the Run | Reload Changed
Classes command. Any classes that have changed since the beginning of the
debugging session are recompiled by IDEA and automatically replace their old
 
 
 
 
 
 
 
 
 
Search WWH ::




Custom Search