Javadoc API: how varargs are supported?

I want to write my own doclet. I do not want to read some existing javadoc, which is made with a standard doclet.

I am having problems with how I can ask the Javadoc API whether the formal parameter is a varargs parameter. For example, if I have the following method:

public static void main(String... args) { } 

How can I determine that the formal argument arguments are varargs? I looked at com.sun.javadoc.Type . But I could not how to access information.

Bye

PS: Reflection does not help, since reflection is not available inside the Doclet, I think. In a doclet, for example, you reflect the MethodDoc class, while in reflection you have the Method class.

+4
source share
2 answers

Found him, his superclass attribute of MethodDoc:

 public interface ExecutableMemberDoc { public boolean isVarArgs(); // Return true if this method was declared to // take a variable number of arguments. } 

To make it work, you must put the following static (sic!)
method and return value in your doclet class:

 public static LanguageVersion languageVersion() { return LanguageVersion.JAVA_1_5; } 

Okie Doki. Case is closed.

+6
source

I think the javadoc API clearly shows if the argument is varargs.

Check below APi

http://docs.oracle.com/javase/1.5.0/docs/api/java/io/PrintStream.html

It has the method below with varargs

format (Locale l, String format, Object ... args )

0
source

Source: https://habr.com/ru/post/1441541/


All Articles