commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Chaffee / Purple Technology <g...@stinky.com>
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...

A.toString 
  new ToStringBuilder()
   B.toString()
    A.toString()
     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                               mailto:alex@jguru.com
Purple Technology - Code and Consulting    http://www.purpletech.com/
jGuru - Java News and FAQs                 http://www.jguru.com/alex/
Gamelan - the Original Java site           http://www.gamelan.com/
Stinky - Art and Angst                     http://www.stinky.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message