The documentation, however, is never propagated to subclasses, because constructors are not inherited1.
It is too bad that I already have to duplicate Constructors in my subclasses, but now I have to duplicate the documentation as well?
Right now, the best solution I can think of is to add a "@see" link to the appropriate super constructor. Like so:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class A | |
{ | |
/** | |
* Lots of juicy javadoc. | |
* @param offset the offset in the array from which to start, 0 and up. Always less than the length of the array. | |
*/ | |
public A(int offset) | |
{ | |
} | |
} | |
public class B extends A | |
{ | |
/** | |
* @param offset See {@link A#A(int)} | |
*/ | |
public B(int offset) | |
{ | |
super(); | |
} | |
} |
There is a feature request/bug2 defined to expand the {inheritedDoc} to also work on constructors. But it has not seen any love for a long time.
References
- [1] StackOverflow - Why is inheritedDoc not defined on constructors?
- http://stackoverflow.com/questions/14848999/why-is-inheriteddoc-not-defined-on-constructors
- [2] JDK-4810216 : Allow {@inheritDoc name} for constructors
- http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4810216
No comments:
Post a Comment