myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McClanahan <craig...@gmail.com>
Subject Re: Why not reuse jsf-api.jar from Sun?
Date Wed, 24 Aug 2005 19:08:36 GMT
On 8/24/05, Ken Weiner <kweiner@gmail.com> wrote:
> > Trust me ... you don't want to read all the EG threads on that topic
> > :-).  But the short answer is, consider what happens in a future
> > version of JSF, when (for good reason) a new method signature is added
> > to the Renderer API.  If it were an interface, you've just broken
> > every current implementation in the world.  As an abstract base class,
> > you can add a default implementation that mirrors the previous
> > behavior, so the only potential breakage is if an implementation had
> > their own version of that very same method signature.
> 
> It seems like you could get the best of both worlds with an interface
> and an abstract class that implements it.  Since this has been
> well-vetted by the EG, I'll accept the reasons it was done without an
> interface.
> 

That certainly would have been possible, and would have broken fewer
people (only those who chose to directly implement the interface
instead of extending the base class), but that wasn't the choice we
ended up making.

> > An actual instance, of course, must be of a concrete class that can be
> > instantiated.  But whether that concrete class extends an abstract
> > base class, or implements an interface, is irrelevant to how many
> > copies there are.  In this particular case, it simply has to be that
> > "instanceof Renderer" returns true, since the JSF implementation is
> > going to cast it to this before calling its methods.
> 
> So, it sounds like the JSF implementation *does* get to choose whether
> or not javax.faces.render.Renderer is an abstract class or in
> interface since an "instanceof Renderer" check could be done for an
> instance of either.  Am I understanding correctly?
> 

No.  Part of the compatibility tests for a JCP spec is a "signature
test" that ensures that every public class (or interface) in the javax
namespace has *exactly* the correct nature (public class, abstract
public class, interface, etc.) as well as *exactly* the correct public
and protected method/variable signatures.  If different
implementations were allowed to choose interface versus base class
(i.e. we threw away the signature tests), then your Renderer
implementation would not be portable -- because the inheritance
hierarchy embedded in your compiled class would be different.

> >
> > Craig
> >
> 

Craig

Mime
View raw message