Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse debug mode view instance variable values

Tags:

java

eclipse

I am trying to view the instance variables values of the Arraylist in eclipse in debug mode but apart from the values in the list am unable to view variables like elementData or modCount that are part of the arraylist. I have tried using Watch, Display option as well but to no avail. Below is my screenshot after setting the breakpoint and triggering the program run:

enter image description here

Below is the screenshot that I found in one of the websites where the instance variables like elementData,modCount and size are visible:

enter image description here

like image 646
Trooper Avatar asked Sep 23 '26 02:09

Trooper


2 Answers

In the current version (Oxygen.3) the default formatter for Collection shows only the members of the collection as an array. I'm not sure when the more detailed formatter was removed, but you can easily create a logical structure formatter.

Right click on the variable in the Variables tab and select Show Logical Structure/Edit Logical Structure

enter image description here

Your view will have the Collection entry hilighted, and won't contain the ArrayList entry I just created.

Add a new entry:

enter image description here

Provide the class name you want to format, and a description. Select List of Variables and then add the variables you want to display, providing a code snippet for each one. The code snippet executes as a method of the class.

enter image description here

End result:

enter image description here

like image 152
Jim Garrison Avatar answered Sep 26 '26 02:09

Jim Garrison


In oxygen, "Show Logical Structure" is enabled by default. All you have to do is click on it to disable it.

enter image description here

[Image taken from eclipse.org]

like image 40
Vasan Avatar answered Sep 26 '26 00:09

Vasan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!