Is it possible to show toString () the result in the value column in the Eclipse debugger?

Is it possible to display toString () result in a column of values ​​in the Eclipse debugger?

By default, it displays values ​​for built-in types and type name + id for user types:

enter image description here

Note that the debugger MAY definitely display toString() , but it only does this in a separate section (below), and not in the Value column.

+5
source share
3 answers

Perhaps if a little awkward. One photo, more than a thousand words:

enter image description here

In the settings, find "Detailed forms." You do not have to specify a simple return command for each type that you want to check (if you want to choose the parts yourself).

Then below, select "Show variable information> As a label for all variables" (if enough for you to specify (),, or "> As a label for variables with detailed formats" if you want to use your own formatting elements The first shows that the "Type + ID" display disappears, because K.

Simple formatter for "not toString ()": Detail Formatter for "other"

+5
source

If the object does not implement the toString() method, you can define your own formatting format. This assumes that the object provides public methods for accessing the fields of interest to you. A good explanation can be found on the Codecentric blog : reporting tips for debugging java using Eclipse . Find the tip "Human readable objects."

0
source

I don’t think it’s possible, because the debugger cannot modify the program, it can just stop or change the execution itself (for example, calls to the skip method, etc.). toString is a method like any other, and the debugger cannot call it.

-1
source

All Articles