Trooper
Trooper

Reputation: 145

Eclipse debug mode view instance variable values

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

Upvotes: 2

Views: 4136

Answers (4)

Shivam
Shivam

Reputation: 116

Go to Window->show view->expressions then in Expressions window go to variables tab there you will see your variables right click on any one of them you will see Show logical structure. Untick the Array option from there and debug again you will see elementData,modCount and size varibles.click here for image

Upvotes: 1

Vasan
Vasan

Reputation: 4956

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]

Upvotes: 3

Jim Garrison
Jim Garrison

Reputation: 86774

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

Upvotes: 5

Dorado
Dorado

Reputation: 431

In some instances that I cannot view variables, like in your case, I would suggest using Expression tab and add new expression. To load expression tab on Eclipse IDE, click on Window > Show View > Expression. Set breakpoint, hit debug, then expression tab should load arrNames and you can expand to view properties and data.

Expression Tab

Upvotes: 1

Related Questions