Stopping Eclipse Debug Interrupt Only When Virtual Calling a Specific Subclass

Say we have an abstract class with the onPoke (..) method.

abstract class BaseValuePanel{ void onPoke(int depth){ //blah, blah, ... } } 
  • The Classes NumberValuePanel, AttributeValuePanel, CategoryValuePanel extend BaseValuePanel.
  • Among others, the DecimalValuePanel class extends NumberValuePanel.
  • Among others, the EstimationValuePanel class extends the DecimalValuePanel.
  • None of the extension classes override the onPoke (..) method.

Now I want to place a breakpoint onPoke (..), but only when I call an object of class EstimationValuePanel.

Because right now, if I set a breakpoint onPoke (..), the debugger would stop thousands of instances (due to the extensive descendant classes of BaseValuePanel), and only one of them was called in EstimationValuePanel.

What is the setup sequence or breakpoint configuration strategy that I need to use to allow the debugger to stop only when the method is called in EstimateValuePanel.

What did I mean by virtual breakpoint ...:
That is, in Java, unlike C #, non-private, non-static (redefined) methods are naturally virtual. Hence, the virtual call is here.

+4
source share
1 answer

Of course, you can override the method in the EstimationValuePanel class and set only a breakpoint there.

But you can also use conditional breakpoints: go to the properties of the breakpoint in the onPoke () method (right-click or double-click Ctrl +) and select "Conditional". In the text area below, you can enter the following condition:

 this instanceof EstimationValuePanel 

This means that the condition is evaluated each time the method is entered. Therefore, if you are having performance issues, you should prefer to override the method in EstimationValuePanel.

+9
source

All Articles