I would like to have Eclipse's Java debugger debug-suspend the monitored process whenever an object of a particular type (class / interface) gets instantiated.
As a workaround, I can set breakpoints
but
To define a breakpoint in your source code, right-click in the left margin in the Java editor and select Toggle Breakpoint. Alternatively, you can double-click on this position. The Breakpoints view allows you to delete and deactivate Breakpoints and modify their properties.
To set a breakpoint in source code: Click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint. The breakpoint appears as a red dot in the left margin.
Select all the methods using ctrl . Right click and select Toggle Method Breakpoint .
Press F3 and then press F9 to add a breakpoint.
You shouldn't need to set breakpoints on superclasses and subclasses. If you put a breakpoint on every constructor of the class you are interested in then every time an object of that class or a subclass of it is created the debugger will hit one of the breakpoints.
This doesn't work for interfaces because they are never constructed. I can't think of a way of doing it for interfaces.
Remember that the default constructor only exists for a class if you don't define any constructor at all, so as long as you have at least one constructor it won't be possible to instantiate an object of that type without using one of the constructors you have written.
See this answer of Carlos Heuberger on this thread.
You can also set a breakpoint on particular class load if you need it. See this tutorial for reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With