1.1.22 Inspecting Nested Objects in the Debugger

The Debugger Can Show Relationships Between Runtime Objects

When a program is paused, debugger windows such as Autos can show more than simple values.

They can also show fields that refer to other objects.

Suppose the runtime relationship is:

Object diagram showing player1 Player object, then player1.team Team object.
Player1PlayerObject.
  • New
  • Changed
  • Removed

Expanding player1 can reveal the nested team reference.

Expanding that Team object can reveal its fields.

This makes the object graph visible one relationship at a time.

Begin at a Meaningful Breakpoint

Suppose the source contains:

Player player1 = new Player();
Team team1 = new Team();

player1.team = team1;
team1.name = "Wildcats";

Set a breakpoint after the relationship and value assignments when you want to inspect the completed state.

When execution pauses, locate player1 in the debugger.

Expand the Outer Object First

You may see something conceptually like:

Object diagram showing pause, then inspect outer object, then expand reference field, then confirm null or object, then expand nested object, then inspect nested fields.
Pause.
  • New
  • Changed
  • Removed

This process prepares you to reason about more detailed object memory and reference behavior in the next batch without guessing from the source alone.