classpath
[Top][All Lists]
Advanced

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

RE: [PATCH] Fix for Hashtable contains blowing up the stack


From: Jeroen Frijters
Subject: RE: [PATCH] Fix for Hashtable contains blowing up the stack
Date: Sat, 22 Nov 2003 13:06:07 +0100

Mark Wielaard wrote:
> On Fri, 2003-11-21 at 20:48, Dalibor Topic wrote:
> > > 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.
> 
> Ugh. That is nasty. Especially since when you override 
> Hashtable it is a natural thing to do since contains and
> containsValue are specced to do the same thing.

The fix is actually incorrect. containsValue() should call contains()
because containsValue() is a new method (since 1.2) and contains()
exists since 1.0. Older code may have overridden contains() and this
should work with newer code that calls containsValue().

As I've argued before, in cases such as these (multiple virtual methods
that do the same thing), we must use the same delegation as the Sun
implementation to be compatible.

Regards,
Jeroen




reply via email to

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