classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [kaffe] Bug Report: StackOverflowError and Collections


From: Dalibor Topic
Subject: Re: [kaffe] Bug Report: StackOverflowError and Collections
Date: Tue, 9 Sep 2003 09:27:45 -0700 (PDT)

--- Tom Tromey <address@hidden> 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.

cheers,
dalibor topic

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]