Time for action – setting up step filtering

Step filtering allows for uninteresting packages and classes to be ignored during step debugging.

  1. Run the test Eclipse application in debug mode.
  2. Ensure a breakpoint is set at the start of the SampleHandler class's execute() method.
  3. Click on the Hello World icon, and the debugger should open at the first line as before.
  4. Click on Step Into Time for action – setting up step filtering five or six times. At each point, the code will jump into the next method in the expression; first through various methods in HandlerUtil and then into ExecutionEvent.
  5. Click on Resume Time for action – setting up step filtering to continue.
  6. Open Preferences, and then navigate to Java | Debug | Step Filtering.
  7. Check the Use Step Filters option.
  8. Click on Add Package and enter org.eclipse.ui, followed by clicking on OK.
    Time for action – setting up step filtering
  9. Click on the Hello World icon again.
  10. Click on Step Into Time for action – setting up step filtering as before. This time, the debugger goes straight to getApplicationContext() in the Execution Event class.
  11. Click on the Resume icon Time for action – setting up step filtering to continue.
  12. To make debugging more efficient by skipping accessors, go back into the Step Filters preference and select the Filter Simple Getters from the Step Filters preference's page.
  13. Click on the Hello World icon again.
  14. Click on Step Into Time for action – setting up step filtering as before.
  15. Instead of going into the getApplicationContext() method, execution will drop through to the ExpressionContext class's getVariable() method instead.

What just happened?

The Step Filters preferences allows uninteresting packages to be skipped, at least from the point of debugging. Typically, JVM internal classes (such as those beginning with sun or sunw) are not helpful when debugging and can easily be ignored. This also avoids debugging through the class loader, as it loads classes on demand.

Typically, it makes sense to enable all the default packages in the Step Filters dialog, as it's pretty rare to need to debug any of the JVM libraries (internal or public interfaces). This means when stepping through the code, if a common method such as List.toString() is called, debugging won't step through the internal implementation.

It also makes sense to filter out simple setters and getters (those that just set a variable, or those that just return a variable). If the method is more complex (like the getVariable() method discussed previously), it will still stop in the debugger.

Constructors and static initializers can also be specifically filtered.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset