Creating a Fixed Watch

A normal watch describes the content of a variable, and a fixed watch describes the object that is currently assigned to the variable. For example, consider the following code:

java.awt.Dimension dim=new java.awt.Dimension(10,20);
java.awt.Dimension newDim=dim;
dim=new java.awt.Dimension(20,30);
newDim.height=15

With the debugger stopped on the second line, you can create a normal watch on the variable dim. If you create a fixed watch on the variable dim, the watch describes the object that is currently assigned to the variable, which is java.awt.Dimension(10,20)). If you press F8 to step over the code three times, the value of the normal watch becomes java.awt.Dimension(20,30). (This change occurred on the third line of source code.) The value of the fixed watch is java.awt.Dimension(15,20). The fixed watch was created on the object with a height of 10, but the fourth line changed the height of this object to 15.

To create a fixed watch:

  1. Select the variable. You can select the variable in the Watches view, Variables view, Threads View, Call Stack view, or Classes view of the Debugger window.
  2. Right-click and choose Create Fixed Watch.

    The watch is added to the Watches view.

See also
Watching the Value of a Variable or Expression
Deleting a Watch

Legal Notices