IntelliJ IDEA enables you to evaluate an arbitrary expression in the context of a stack frame currently selected in the Frames pane of the Debug window. The following modes are available:
- Expression Mode for evaluating single-line expressions.
Code Fragment Mode
for evaluating short code portions introducing them in the
Statements to evaluate
Supported constructs are declarations, assignments, loops and
Besides that, IntelliJ IDEA provides a way to quickly evaluate an expression in the editor at caret or a selection.
To evaluate an arbitrary expression
- In the Frames pane, select the thread where you want an expression to be evaluated.
in one of the following ways:
- On the main menu, choose Run | Evaluate Expression
- On the context menu of the editor, choose Evaluate Expression
- Press Alt+F8
- Click on the stepping toolbar of the Debug tool window.
- Select the desired mode of evaluation. If you want to evaluate a code fragment, click the Code Fragment Mode button.
- Depending on the mode selected, type the expression or statements to evaluate in the text field.
- Click Evaluate. If the specified expression cannot be evaluated, the possible reason will be briefly described in the Result pane of the dialog box.