DZone Forums
Go Back   DZone Forums > Community > Languages & Frameworks > Java
Reload this Page library for dumping object content via reflection
Notices
Reply
 
LinkBack Thread Tools Display Modes
  (#1 (permalink)) Old
Member
 
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Aug 2008
Default library for dumping object content via reflection - 08-25-2008, 06:52 AM

jbeandumer - Google Code

Small library that dumps Java object state into human readable format (similar, but not exact, to JavaFX literal). For example:

Code:
Dumper dmpr = new Dumper();
System.out.println(dmpr.dump(new Date()));
prints:

Code:
java.util.Date{
   cdate : null
   fastTime : 1218288272098
}
Another example:

Code:
Dumper dmpr = new Dumper();
dmpr.setRadix(16); //You could use radix up to Character.MAX_RADIX, 31 for example :-)
dmpr.setIDENT("\t");
System.out.println(dmpr.dump(new ByteArrayInputStream("123456789".getBytes())));
prints:

Code:
java.io.ByteArrayInputStream{
	buf : [ // byte[9]
		31h, 32h, 33h, 34h, 35h, 36h, 37h, 38h, 
		39h
	]
	count : 9h
	mark : 0h
	pos : 0h
}
Current status: v 1.3 seems to be production ready, at least I use in my project.
Reply With Quote
  (#2 (permalink)) Old
Administrator
 
matt's Avatar
 
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
Join Date: Jan 2008
Default 08-27-2008, 09:54 PM

Pretty neat. It can be a real pain in the rear to see a nicely formatted view in the console of your object state. What have you been using it for? I suppose its very helpful if you can't attach a debugger to your code.
Reply With Quote
  (#3 (permalink)) Old
Member
 
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Aug 2008
Default 08-28-2008, 06:13 AM

It is very useful for error diagnostics. For example: some example occurred while executing middleware request (request is an object). If I could automatically dump request, responce, session state to separate files (+all previuos session requests), zip it and attach to JIRA issue it is really helpful.

Not all bugs fires when debugger is attached. Sometimes it happens in production on the other side of the Earth, 12 hours ago.

But anyway you need to catch this irregular bug and fix it.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Show JRE library in project? lumbergh Eclipse 3 06-11-2009 02:27 AM
how to send object using j2me jay_goh Java 2 02-04-2009 09:08 PM
Help needed - Trouble in using Reflection in JRE 1.5 karthik7_7 Java 1 01-27-2009 06:03 AM
Web App Library Empty?! burtonrhodes Eclipse 0 12-04-2008 09:24 AM
eclipse/vistajava.lang.NoClassDefFoundError: –Djava/library/path=//lib Exception main adhoul Eclipse 1 11-15-2008 11:52 AM


Copyright 1997-2009, DZone, Inc.
vBulletin Skin developed by: vBStyles.com