Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why does Eclipse import a class when referencing it with @See

Why does Eclipse add an import for the target class of a Javadoc @see comment?

If you run this through findbugs or PMD they complain that its an unused import.

So which is correct? Personally I can't see why eclipse wants to import it.

 import java.util.List;
 /**
 * @see List
 */

The same is true for 'link'

 import java.util.List;
 /**
 * {@link List}
 */

Does any have any ideas why?

like image 356
jeff porter Avatar asked Oct 20 '25 15:10

jeff porter


1 Answers

The important thing to understand about import statements are that they are simply a convenience mechanism for the developer to avoid having to use the Fully Qualified Name (FQN) for a Type everywhere. For example, importing java.util.List will let you refer to it by simply using the simple name List as opposed to using java.util.List everywhere.

Imports have no effect on the efficiency or size of the generated bytecode since their use is as explained above and they do not cause any classes to be 'linked' or anything like that with your class.

In the case of the JavaDoc comments, if you use the FQN , Eclipse wouldn't need to import in order to resolve the Type reference. As it is, you're using the simple name which is ambiguous so Eclipse imports the appropriate Type.

like image 193
no.good.at.coding Avatar answered Oct 22 '25 03:10

no.good.at.coding



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!