Suzan Cioc
Suzan Cioc

Reputation: 30097

How to find an instance constructor call in Java debug in Eclipse?

I stopped at some breakpoint in some object instance. I have multiple instances of this class, called in various place.

Is it possible to find that constructor call, which has created namely this instance?

Constructor call is not in stack in the case.

Upvotes: 1

Views: 793

Answers (1)

E-Riz
E-Riz

Reputation: 32914

No, that's not possible; as @ajb's comment says, the constructor call is long gone by the time the object is used in other ways.

One option you have is to set a breakpoint in the constructor and note the object ID of each instance as it passes through the constructor (Object ID is visible in the Variables view, as the value of this.

enter image description here

Then when the other breakpoint is hit, you can look at the ID and know which object it refers to.

Upvotes: 2

Related Questions