Suzan Cioc
Suzan Cioc

Reputation: 30127

Breakpoint filter by subclass?

Is it possible to set breakpoint so that it stop only if the given method is called from subclass?

I.e. both a method defined and breakpoint set are in superclass. Method is not overridden in subclass but is called for it. I need to catch only those cases, when it happen from given subclass.

This is suitable to track incorrect usage in highly branched libraries. For example class VeryCoolAncestor is called 1000 times, while only 1 of the calls are of my buggy class B.

I would like to know if it is possible in Eclipse. If it is not possible in Eclipse, then I would like to know any other debuggers where it is possible.

I need automation, so I don't need to know workarounds like inserting test calls in the code or test overriding methods.

Upvotes: 2

Views: 556

Answers (1)

Maroun
Maroun

Reputation: 95978

You can use conditional breakpoints in Eclipse.

Right click on the breakpoint, then select "Breakpoint Properties", then enable the "Conditional" checkbox and add an instanceof statement that satisfies your requirements:


enter image description here

Or, you can write a block just for debugging purposes, having one statement:

if(someCondition) {
    System.out.println("Breakpoint here");
}

Upvotes: 2

Related Questions