Java Reference
In-Depth Information
wish, you can have the debugger use an object's toString() method to generate
the display name. To do so, right-click an object reference in the stack view, and
select the View toString() option. Selecting it again turns off this option, revert-
ing back to the default object view. You can also set the String value view to be the
default view for object instances on a class or package basis, as described later in
this chapter.
If a string value is too large to fit on a line in the stack frame view, it is
truncated. You can view the full contents of the String by hovering your
mouse pointer over it to display its contents in a tooltip window. Alterna-
tively, right-click the value, select the Copy Value option to copy the val-
ue to the clipboard, and then paste into another text editor or a scratch
file; you can then examine the contents of the value no matter how large
it is.
TIP
Viewing the contents of an array
The debugger displays arrays as a tree of values. The top node represents the
array itself, and its children are the contents of the array. As with other objects,
you can further inspect each member of nonprimitive arrays. To show a subset of
the array's members, right-click the array node and selecting the Adjust Range
option, which lets you specify the first and last index you're interested in.
Peeking at variable values in the editor
Another handy way to inspect the value of references is through the editor. When
you have a stack frame visible in the debugger, visiting the source code of any of
the class allows you to see the value of any variable in a tooltip by hovering your
mouse pointer over the variable reference in the source code. The value dis-
played is determined by the context of the current stack frame. If the current
stack frame doesn't reference the class, you don't see a value of its members. The
only exception is static members, which don't require a context.
Evaluating arbitrary expressions
Another handy feature of the debugger is its ability to evaluate arbitrary expres-
sions in the context of the current stack frame. To access the expression evaluator,
click the Evaluate Expression icon in the debugger's toolbar or select the Run |
Evaluate Expression menu option ( Alt+F8 ) to bring up the dialog shown in fig-
ure 6.11. Alternatively, you can select a reference in the Frame view, in the inspec-
tion window, or within the source code editor, and select Evaluate Expression
 
 
 
 
 
Search WWH ::




Custom Search