Java Reference
In-Depth Information
The first option, Field access , tells the debugger that you wish to trigger the
breakpoint any time the field is accessed. This could involve initialization, read
access, or write access. The second option, Field modification , says that you only
care about changes to the field. Simple read attempts won't cause the breakpoint
to trigger. You must select at least one of these options.
6.2.6
Setting conditional breakpoints
Breakpoints needn't be absolute. You can also create breakpoints that take effect
only under certain conditions and situations. This gives you a much finer degree
of control, allowing you to spend more time debugging and less time stepping
through program code.
Breaking only when a certain condition is true
This option lets you specify a logical condition for activating the breakpoint's
action. The condition is any valid Java expression that evaluates to a boolean
( true / false ) value at runtime. This expression is evaluated in the context of the
current line, so it can use any available fields, methods, or variables available at
that point. For example, any of the following represent valid boolean expressions,
assuming the referenced variables are accessible at the breakpoint:
time >= 100
user.getRoleId() == STUDENTROLE
response != 0 && response > 12
Notice that these are expressions, not lines of code or statements—don't end the
expression with a semicolon. To set the break condition, enter the expression in
the Condition field of the Conditions option group, and enable it by selecting
the appropriate checkbox. Your expression isn't validated until the debugger
reaches it, so type carefully! If you make a mistake and enter an invalid expres-
sion, you'll be notified when it's reached and given the option of breaking.
You can use IDEA 's code-completion features to help construct your
expression.
TIP
Breaking only for certain instances
The Instance filters option lets you activate a breakpoint for particular instances
of the class within the VM . Each object in the VM is assigned an instance ID at cre-
ation time. You can see this instance ID in the debugger's view of the stack frame
as the number following the @ sign next to an object reference. Unfortunately, you
can't predict the instance ID value—it's not necessarily sequential. Instance ID s
 
 
 
 
 
 
 
Search WWH ::




Custom Search