Eclipse issue w/Java imports, doc comment links, and type parameters

T

Twisted

This is unexpected behavior and a problem:

I have a sourcefile where one of the doc comments contains:

{@link ETF#getIteratorInstance(Options, Parameters)
ETF.getIteratorInstance}

It's impossible to "organize imports" in Eclipse when editing this file
now. It highlights Parameters in this doc comment and wants me to pick
either java.security.Policy.Parameters or
javax.security.auth.login.Configuration.Parameters, and does not
provide the option to skip doing so but still import whatever else
(e.g. HashSet) has been referenced and needs importing.

The code itself does not actually reference Options or Parameters,
which are actually type parameters to the class ETF. It is only this
one @link doc tag that references them as part of the signature of the
linked-to method. Neither of the Parameters classes suggested as
imports are at all useful or relevant here.

This is a significant wart, though not a showstopper. Organize imports
should, it seems to me, limit itself to what's actually used by the
Java code, and if javadoc needs this to find them, types actually
linked to in comments (in this case ETF but not Options or Parameters).

This looks likely to be a result of the relatively recent introduction
of generics. Let's hope this sort of thing is smoothed out in the next
version of Eclipse (and, if partially responsible, javac and/or
javadoc)...
 
T

Twisted

Twisted wrote:
[snip]

P.S. it seems that Java's generics, though less complex or
well-developed than C++ templates owing to the need for backward
class-file compatibility, are nonetheless sufficient in capability to
enable type-parameter spaghetti. :) Perhaps even more so than
templates, since javac is much smarter about resolving backward
references and coping with the circular referencing of types without
having to declare everything once and then define everything
once...OTOH, *nothing* compares to the #include spaghetti that any
substantial circularly-referenced group of C++ classes forces on the
poor benighted coder who has to write the header files!
 
T

Twisted

Twisted said:
This is unexpected behavior and a problem:

I have a sourcefile where one of the doc comments contains:

{@link ETF#getIteratorInstance(Options, Parameters)
ETF.getIteratorInstance}

I've got some more information now. It's actually the *autocomplete* in
Eclipse that is stuffing this up. It should really be filling this in
with ETF#getIteratorInstance(Object, Object) with these type
parameters, and more generally, with whatever the type parameter
extends, rather than
the name of the type parameter itself. Manually changing
type-parametrized @link and @see references to replace type parameter
names with the erased types is needed to make the links work in the
compiled javadocs too.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top