How does verbose forms debugging allow classes in eclipse?

In eclipse, you can set custom "Detailed forms" under "Settings" → "Java" → "Debugging" → "Detailed forms" for printing objects in user modes during debugging. I would like to use a utility class to print an object using formatting, for example:

return com.foo.Bar.xzyToString(this);

where xzyToString is the static Bar method returning String, but eclipse complains that it is

'failed to resolve type: com.foo.Bar.xzyToString'. Adding "Bar" to the build path of the project does not allow you to find the class. How / where am I updating the path used by eclipse for resolving names in verbose formats?

+3
source share
3 answers

Part formatting is built into the Eclipse JDI framework and uses the class class loader, which is currently being debugged. Thus, you can use only those classes that your running application knows about.

Since you only need your utility class when debugging, you can add the class to the path to the startup configuration class (or add it directly to your project). Unfortunately, I do not know how to do this automatically for all starts.

+3
source

, . , , , , .

, - :

if ( Class.forName("com.foo.Bar") != null ) {
  return com.foo.Bar.xzyToString( this );
}
else {
  return "Could not load com.foo.Bar in detail formatter!";
}
+1

Just pass the item after the instructions return. For instance. for StringBuffertry:

toString() + " (" + length() + ")"
-1
source

Source: https://habr.com/ru/post/1761319/


All Articles