liveBook · Manning

Drop frame

As explained in Troubleshooting Java, Second Edition

A debugger operation that returns execution to an earlier point in the call stack and re-runs a method from that point.

Drop frame rewinds a debugger to the point before a method was called, allowing that method to run again without restarting the application. It moves one layer back in the call stack and replays the call by stepping into or over it. section 3.4

Use it when a method needs another inspection after stepping into it. Unlike stepping out, which lets the method finish and pauses afterward, dropping a frame returns before the call so execution can be replayed. section 3.4

Investigate with these practical checks:

  • Inspect the execution stack and select the method layer to revisit. section 3.4
  • In IntelliJ IDEA, right-click the method’s stack layer and choose Drop Frame. section 3.4
  • Confirm whether the method already changed a database, filesystem, or external application; rewinding execution does not undo those effects. section 3.5

A replay with a side effect

Suppose the debugger pauses in extractDigits(), called by decode(). Stepping out finishes extractDigits() and pauses in decode(); dropping the frame returns to the line before extractDigits(), where the call can be replayed. A method such as Files.createFile(Paths.get("File " + i)) warns that replaying execution may attempt an external filesystem change again. section 3.4

How Troubleshooting Java, Second Edition covers it

How deep it goes
Explains stack movement, replay, stepping-out differences, IDE operation, and irreversible side effects.
Examples
Demonstrates extractDigits() called by decode() and Files.createFile() changing the filesystem.
What it assumes
Assumes an active debugger investigation with an execution stack and a paused method call.
What you can do after
Diagnose/debug with it by returning before a method call and replaying execution without restarting the application.
How it connects
Connects the debugger, call stack, stepping out, method execution, and external side effects.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Troubleshooting Java, Second Edition. The section links point to the parts of the book it draws on.