2

Suppose I have this:

/** * Single-word method. */ private void say(String word) { System.out.println("Single word: " + word); } /** * Multiple-word method. */ private void say(String... words) { System.out.print("Multiple words: "); for (String word : words) { System.out.print(word); } System.out.println(); } /** * {@link #say(String...)} */ @SuppressWarnings("unused") private void testJavadoc() { } public static void main(String[] args) { say("hello"); say("world"); say("hello", "world"); } 

If I run this, I get:

Single word: hello Single word: world Multiple words: helloworld 

This proves that there is nothing wrong in defining a method with String and an overload with String....

When I mouse-over testJavadoc(), this is the Javadoc I see:

void testJavadoc() @SuppressWarnings(value={"unused"}) say(String) 

Clicking on say(String) brings me to the Javadoc for the first method without vararg.

If I remove say(String) method, then the Javadoc works fine.

I'm using eclipse neon 3 (4.6.3). Is this supposed to be the correct behavior?

1
  • {@link #say(String[])} works perfectly in the popup javadoc window, but it does not convey that there is a vararg parameter Commented Nov 18, 2017 at 7:45

1 Answer 1

1

This looks like it might be a bug in Eclipse, as you are correct in that it should reference the vararg method (I don't have Eclipse so I am unable to test).

Testing in IntelliJ, I can see the expected reference.

More-so, if you go ahead and actually generate the JavaDoc, you should be able to see the correct output.

Generated JavaDoc

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, at least I can conclude it's the problem with Eclipse now.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.