9.2. Breakpoints

Once DrJava is in Debug Mode, you can set a breakpoint on almost any line of code in a source file in the Definitions Pane, using either the "Toggle Breakpoint on Current Line" command in the Debugger menu or the "Toggle Breakpoint" command on the context (right-click) menu in the Definitions Pane. When a breakpoint is set, the line will be highlighted in red and an entry will appear in the Breakpoints tab of the Debug Panel. A breakpoint is reached when a method is called in the Interactions Pane and the control flow reaches a line of code where a breakpoint has been set. When this happens, DrJava highlights the line in bright blue and prints a message to the Interactions Pane. DrJava then displays a new prompt in the Interactions Pane, allowing you to interact with the suspended program until it is resumed (see Interactions at a Breakpoint).

When setting breakpoints, it is important to remember that only lines with actual executable code can be used. Blank lines and comments will never trigger a breakpoint, even if the line is highlighted in red. (Note that we do not yet support breakpoints on method contracts either, although this will be supported in a later version of DrJava.)

Debugging JUnit Tests. DrJava will also stop at breakpoints during JUnit tests. Simply set a breakpoint on a line of a test method or in a method called by a test, and then choose the "Test Using JUnit" command from the Tools menu. When control flow reaches the breakpoint, the test will be suspended.