Re: Forcing sub-classes to implement Constructor
Randall R Schulz <[email protected]>
| Newsgroups | gmane.comp.windows.devel.java.advanced |
|---|---|
| Message-ID | <[email protected]> |
On Thursday 09 August 2007 08:14, Jeff Kesselman wrote:
> Brian Maso wrote:
> > No.
> >
> > Constructors are more like static methods than regular methods:
> > they can't be declared abstract and thus force subclasses to have
> > them. You can add tools to your build to recognize certain
> > annotations that trigger verifier rules. For example, you could
> > define an annotation such as:
>
> Hmm. Brian appears to be correct after a quick test.
>
> Whats weird is that I *know* I've seen situations where the
> definition of a super class contrutctir forced the definition of sub
> class one...
I think this would do it:
class Super
{
private
Super()
{
}
protected
Super(...)
{
...
}
}
class Sub
extends Super
{
// Implicit default constructor implicitly calls super()
// which is private, forcing the definition of a constructor
// to call an accessible Super constructor
}
> JK
Randall Schulz
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com