Issue
I'm looking for the equivalent functionality of IntelliJ IDEA "Mark instance" in Eclipse Debug.
I've searched extensively also in documentation, but I think this feature is not existing in Eclipse Debugger. I can count instances, I can find references, but appears there is no way in the "Variables" window to mark a specific instance with ID with a visual label for convenience while debugging. Before giving up, I preferred to ask also this audience.
Practical example
Assuming the following (minimal, easy, synthetic) example code:
Object obj1 = "Hello World";
Object obj2 = 12345L;
Object result;
if (Math.random() > 0.5) {
result = obj1;
} else {
result = obj2;
}
System.out.println(result);
if I put a breakpoint on the System.out line, I'd like to know if the instance of variable result
is the same instance of variable obj1
.
Using IntelliJ IDEA
This can be done by "Mark instance" on obj1
:
As you can notice a visual label is applied to all the variable sharing the same instance reference, in this case also result
:
Using Eclipse Debug
Appears there is now way to have the Eclipse Debugger visual mark instance ID=16 in order to recognize which other variables are sharing the same instance as of obj1
.
(Of course this is a simplified example and it's visually easy to detect it even without this feature, but in a real case it would be a very helpful way to understand where an instance is shared across "Variables" and a great additional tool for debugging)
Thanks!
Solution
Eclipse 4.22 now has a feature for "marking a specific instance with ID with a visual label for convenience while debugging"!
(End of 2021, almost 5 years after the OP)
Label Objects during debugging
During debugging a Java application, often we have to deal with lot's of object instances, and it's not always easy to distinguish between them.
That's why the experience is improved, with the ability to set a label on individual objects.
After setting a label, everywhere the object appears it is displayed with a distinctive color and with the label:
Answered By - VonC
Answer Checked By - Candace Johnson (JavaFixing Volunteer)