Re: Forcing sub-classes to implement Constructor
Brian Maso <[email protected]>
| Newsgroups | gmane.comp.windows.devel.java.advanced |
|---|---|
| Message-ID | <20070809145639.KFPQ23215.fed1rmmtao104.cox.net@fed1rmimpo01.cox.net> |
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: @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