commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Chaffee / Purple Technology <>
Subject Re: [lang] ToStringBuilder thread local
Date Thu, 10 Apr 2003 01:12:18 GMT
When I looked at this (a recursive reflective toString) a few months
ago, it appeared that the visited set did indeed need to be stored in
a ThreadLocal.  Why?  Because if A points to B, which has its *own*
toString, and which points to A...

  new ToStringBuilder()
     new ToStringBuilder()...  
      (which doesn't know that A has already been done.)

One common case of this is if B is a List.

But like I said this was a while ago, and I'd have to to some mental
calisthenics to confirm it with the present code.  And it depends how
deep you want to go.

Anyway, just contributing food for thought.  Snack food at least.

 - A

PS It occurs to me that this is the same problem tackled by
ObjectOutputStream.  I know it's possible to provide your own
implementation for that... Hmmm...

Alex Chaffee                     
Purple Technology - Code and Consulting
jGuru - Java News and FAQs       
Gamelan - the Original Java site 
Stinky - Art and Angst           

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message