Dimitri Missoh
enthusiastic technologist and problem solver

October 20th, 2008

Use conditional breakpoints to simulate a bug or system out in third party code

Suppose you want to system out the value of a variable your are interested in or even change it value to simulate a bug during a debug session in a third party code, e.g. in a packaged library. We assume that you download the source code and attach it to your library. Since you are compiling your code again the library, you can neither change any part of the code located in the library nor compile it to see the effect of your change. You can easily achieve this task in eclipse using conditional breakpoints. Just double click to add a breakpoint as usual and use the context menu on this breakpoint to open the “Breakpoint Properties” dialog. The default option stops the debugger at a conditional break point only if it returns true. So terminate you code block with a return false, to no interrupt the code execution. Screenshots show two use cases. In the first one we use this feature to system out the value of a given label, and in the second example we use conditional break point to set the value of the variable window to null to simulate a bug and see how our code react on a null pointer exception.

System out with conditional breakpoints

Set a variable to null with conditional breakpoint