Re: Forcing sub-classes to implement Constructor

Jeff Kesselman <[email protected]>
Newsgroups gmane.comp.windows.devel.java.advanced
Message-ID <[email protected]>
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...

JK
>
> @SubclassConstructorRequiredPattern(presense=REQUIRED,
> constructor=PUBLIC_DEFAULT)
>
> which would be applied to the base class. Some part of your build then
> would scan code either jsut before or just after compilation to see if
> it breaks all the rules defined by such annotations.
>
> Sounds like an awful lot of work, though. What's your use-case? Why do
> you ned subclasses to supply a public default constructor?
>
> Brian Maso
>
> At 07:13 AM 8/9/2007, you wrote:
>> Is there a way to force subclasses of a class to implement a certain
>> (read
>> empty) constructor.
>>
>> mvh roger j
>>
>> ===================================
>> This list is hosted by DevelopMentor®  http://www.develop.com
>>
>> View archives and manage your subscription(s) at
>> http://discuss.develop.com
>
> ===================================
> This list is hosted by DevelopMentor®  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.