Ability to list a method in the Constructors summary

Nir Lisker nlisker at gmail.com
Wed Oct 3 06:49:43 UTC 2018


Hi Jon,

Thanks for the info.

If I bring it up on the Java subreddit and see what people say, would it
count as a measure for interest? How is "sufficient interest" evaluated,
more or less?

- Nir

On Wed, Oct 3, 2018 at 2:27 AM Jonathan Gibbons <jonathan.gibbons at oracle.com>
wrote:

>
>
> On 10/02/2018 06:54 AM, Nir Lisker wrote:
>
> Hi,
>
> Many static methods are used to obtain an instance of a class, functioning
> as a de-facto constructor and sometimes replacing it altogether. These are
> factory or builder methods and the like.
>
> The problem is that while they function as constructors, they are hidden
> between the rest of the methods in the JavaDoc. It is my understanding that
> the Constructors section shows how to create an instance, while the Methods
> section shows how to use it. In this case, the aforementioned methods will
> fit better in the Constructors section.
>
> One way this can be solved is via an annotation on the method that would
> list it under the Constructors, used at the developers discretion. As an
> example, Toolkit is a singleton:
>
> public class Toolkit {
>
>     private final Toolkit TOOLKIT;
>
>     private Toolkit() {  ...  }
>
>     @Constructor
>     public static getDefaultSystemToolkit() { return TOOLKIT; }
> }
>
>
> The annotation shows the intended way for a developer to obtain the
> instance.
>
> I can submit an RFE if this is plausible. Otherwise, I'm open for other
> solutions if you agree with the problem I presented.
>
> - Nir
>
>
> Nir,
>
> It's not an unreasonable request, and has been suggested before, dating
> back to 2002.
>
> That being said, there has not been sufficient interest to make it happen.
>
> See this JBS issue for one of the early requests:
> https://bugs.openjdk.java.net/browse/JDK-4619333
>
> -- Jon
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/javadoc-dev/attachments/20181003/fec3c13a/attachment.html>


More information about the javadoc-dev mailing list