Reputation: 8363
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?
Upvotes: 2
Views: 362
Reputation: 1558
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.
Upvotes: 1