Forum Controls
Spotlight Features
Replies: 6 - Pages: 1  
Threads: [ Previous | Next ]
  Click to reply to this thread Reply

Eclipse: Debugging with Detail Formatters

At 4:50 PM on Dec 16, 2004, R.J. Lorimer wrote:

Ever written a toString() method to ease debugging? I bet you have, as that is the primary reason for writing a toString() method in the first place. Ever worked with an external API that didn't have well thought-out toString() implementations? I bet you have - all too often the output looks something like this:



Eclipse has a feature called detail formatters, which essentially override the default behavior of using toString() to get the formatted information for an object in the variables view. To set up a detail formatter, go to Window->Preferences->Java[+]->Debug[+]->Detail Formatters and add a new detail formatter. For a class like this:

public class WidgerFurmuzzit {
 
	private String name;
	public WidgerFurmuzzit(String name) {
		this.name = name;
	}
	public static void main(String[] args) {
		
		Object o = new WidgerFurmuzzit("Test, 123");
		System.out.println(o);
	}
}


Here is a valid example detail formatter:



Notice that the detail formatter has visibility to private members inside the object, which is a clear advantage over traditional System.out.println() techniques outside the debugger. Here is the final result of having the detail formatter enabled:



Detail formatters can be enabled and disabled during the execution of a program, so if you suddenly find a new object that you want to know more about during debugging without having to sift through all of the variable trees, just put a new detail formatter in and keep going.
1 . At 9:38 AM on Dec 17, 2004, Joe Attardi wrote:
  Click to reply to this thread Reply

Re: Eclipse: Debugging with Detail Formatters

R.J., once again a great tip. I run into this problem far too much and it's quite annoying. We wouldn't even need this if people actually wrote proper toString() methods, but in the meantime, this looks great!
-- Joe Attardi
2 . At 4:58 AM on Dec 21, 2004, Osvaldo Doederlein wrote:
  Click to reply to this thread Reply

Re: Eclipse: Debugging with Detail Formatters

This particularly useful for tool-generated code, like CORBA stubs -- even if you have the sources, you can't reasonably edit'em manually to insert a decent toString(), because the changes will be lost in the next re-generation of those sources.
3 . At 7:54 AM on Aug 6, 2007, Varun Reddy wrote:
  Click to reply to this thread Reply

Re: Eclipse: Debugging with Detail Formatters

For some reason cannot view the screen shots for the Debugging with Detail Formatters. I get the following error message:

Forbidden
You don't have permission to access /images/postings/rj/detail_formatters/1.gif on this server.

It would be great if its possible to get to see those screen shots.

Cheers,
Varun.
4 . At 2:00 PM on Aug 8, 2007, Jim O'Flaherty, Jr. wrote:
  Click to reply to this thread Reply

I cannot see the pictures...

I have Firefox and am unable to see the embedded pictures. Are the available elsewhere?
5 . At 2:43 PM on Aug 10, 2007, perlon wrote:
  Click to reply to this thread Reply

Re: I cannot see the pictures...

such problem )

phentermine no prescription
acyclovir
acyclovir


+ phentermine cod
+ phentermine cod +.

+ phentermine no prescription
+ phentermine no prescription
+ phentermine no prescription

+ cyclobenzaprine +.
+ cyclobenzaprine +.
+ cyclobenzaprine +.

+ butalbital
phentermineonline
altace online
mp3 downloads
mp3 downlowds

6 . At 7:09 PM on Aug 20, 2007, Javanewcomer wrote:
  Click to reply to this thread Reply

Re: I cannot see the pictures...

Me too, please fix these pics.
It's very useful for me.
Thanks.
Java Tutorial
Java Software

thread.rss_message