[kaffe] Bug Report: StackOverflowError and Collections
robilad at yahoo.com
Tue Sep 9 09:30:02 PDT 2003
--- Tom Tromey <tromey at redhat.com> wrote:
> >> Basically, LazyHashtable.contains(Object value) calls
> >> super.contains(Object value) in Hashtable, which in Classpath's
> >> implementation, calls Hashtable.containsValue(Object value).
> >> Unfortunately, LazyHashTable.containsValue(Ojbect value) overrides that,
> >> just calling calling LazyHashTable.contains(Object value) again, and we
> >> have a loop.
> It isn't clear to me that this is definitively a Classpath bug. Who's
> to say there isn't currently-working code out there that does the
> opposite? The JDK docs certainly don't specify this sort of thing.
this is a typical java library bug, and I've both produced and fixed a couple
of those myself ;) You get an infinite recursion through calling overridden
methods. Class A in library implements public methods b and c, where b
internally (and of course undocumentedly ;) calls c. Class B from some user of
the library extends A and overrides c to call b. When the user calls the method
b of class B it goes straight into an infinite loop.
The fix is to avoid calling overridable methods from overridable methods, and
to delegate those calls to internal, non-overridable versions of the methods.
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
More information about the kaffe