Conditional breakpoint on outer class of superclass of anonymous class

Answered

If that title sounds cryptic, let me show you the class structure (in API) that I have to work with:

public class Model {
public final void foo() {
// breakpoint is here
}
}

public class View1 {
private Model view1Model = new Model() {
...
}
}

public class View2 {
private Model view2Model = new Model() {
...
}
}

As you see, Model is the superclass of both anonymous classes.

I want to change the breakpoint to a conditional breakpoint that breaks only when the outer class of the anonymous class of `xxxModel` is `View2`. The class Model does not hold a reference to the outer class.

When broken at the breakpoint, I can see in the inspector that `this.this@0 == View1@1441` and I can add this phrase (`this.this@0`) as a watch (even though it's colored red as if an error, it works.) However, if I add that same phrase to the breakpoint then the VM cannot handle it and I get a breakpoint error when the breakpoint is reached.

 

[edit] I meant anonymous classes, not inner (although inner classes of Model also appear in the API)

 

 

3 comments
Comment actions Permalink

The need for this has subsided, as I've debugged my way through the API with more effort, but it would be nice to eventually have an answer anyway.

0
Comment actions Permalink

I suppose you can try using conditional breakpoint with the condition that checks the class name like this.getClass() or use wildcards in the class filter.

0
Comment actions Permalink

Thanks, that seems to work.

this.getClass().getName().startsWith("View2")
0

Please sign in to leave a comment.