Bug 253750

Summary: [javadoc] Compiler warning about never used imports when import is enum used in JavaDoc
Product: [Eclipse Project] JDT Reporter: Thomas Schindl <tom.schindl>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jerome_lanneluc, markus.kell.r, philippe_mulet
Version: 3.4.1   
Target Milestone: 3.5 M4   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Proposed patch none

Description Thomas Schindl CLA 2008-11-04 12:43:11 EST
I have a class like this:

-------8<-------
package org.ufacekit.ui.layouts;

import org.ufacekit.ui.layouts.properties.OrientationPropertyOwner;
import org.ufacekit.ui.layouts.properties.OrientationPropertyOwner.Orientation;

/**
 * box layout where the controls are laid switch the
 * <code>orientation</code> :
 * <ul>
 * <li> {@link Orientation#HORIZONTAL}, the controls are laid out from left to
 * right in the order that they appear in the box.</li>
 * <li>{@link Orientation#VERTICAL}, the controls are laid out from top to
 * bottom.</li>
 * </ul>
 */
public interface UIBoxLayout extends UILayout, OrientationPropertyOwner {

}
-------8<-------

and the UI here shows an "unused import org.ufacekit.ui.layouts.properties.OrientationPropertyOwner.Orientation" though I'm using it in the JavaDoc.
Comment 1 Markus Keller CLA 2008-11-05 14:00:58 EST
I guess you inadvertently disabled Javadoc processing on the Java Compiler > Javadoc preference/properties page.

*** This bug has been marked as a duplicate of bug 92821 ***
Comment 2 Philipe Mulet CLA 2008-11-06 05:24:14 EST
Markus - could a quickfix help there ? (like check the setting for javadoc processing and trigger appropriate action if not)
Comment 3 Markus Keller CLA 2008-11-06 05:48:08 EST
> Markus - could a quickfix help there ? (like check the setting for javadoc
> processing and trigger appropriate action if not)

That would be hard to implement with acceptable performance. We would basically have to compile the whole CU again with Javadoc processing enabled to find out whether an import would still be unused then.

I adjusted the preference label a bit to make it more clear that also content assist and imports are affected by this setting.
Comment 4 Thomas Schindl CLA 2008-11-06 07:04:38 EST
(In reply to comment #1)
> I guess you inadvertently disabled Javadoc processing on the Java Compiler >
> Javadoc preference/properties page.
> 
> *** This bug has been marked as a duplicate of bug 92821 ***
> 

No because when I do this with a class it works the problem is only with the enum or is it an inner class problem?
Comment 5 Philipe Mulet CLA 2008-11-06 07:26:34 EST
Got it. The import is truly not necessary, since Orientation is accessible without the import based on the fact you import its enclosing type already (OrientationPropertyOwner), and UIBoxLayout extends OrientationPropertyOwner.
Member types are inherited from super types...

So you can discard the import, and everything will work fine.
The compiler warning is thus accurate.

------------------------

Reproduced with standard testcase:

import java.util.Map;
import java.util.Map.Entry;
/**
 * <li> {@link Entry} </li>
 */
public interface X extends Map {
}


Now, the next question is: Markus, organize imports will insert an unused import (try organize imports on the following testcase).

import java.util.Map;
/**
 * <li> {@link Entry} </li>
 */
public interface X extends Map {
}
Comment 6 Philipe Mulet CLA 2008-11-06 07:27:59 EST
Hmm I spoke too fast. There seems to be an issue in javadoc resolution when removing the unused import, need to double check what's going on there.
Comment 7 Markus Keller CLA 2008-11-06 08:16:56 EST
> Member types are inherited from super types...

This is only true for references in Java. The Javadoc tools has its own rules, see http://java.sun.com/javase/6/docs/technotes/tools/windows/javadoc.html#specifyingname :
o Nested classes must be specified as outer.inner, not simply inner, for all forms.
Comment 8 Markus Keller CLA 2008-11-06 08:23:36 EST
See also bug 222188.
Comment 9 Thomas Schindl CLA 2008-11-06 08:25:09 EST
Ok when I use OrientationPropertyOwner.Orientation in JavaDoc it works and the "import org.ufacekit.ui.layouts.properties.OrientationPropertyOwner.Orientation" is not needed any more.
Comment 10 Philipe Mulet CLA 2008-11-06 09:00:24 EST
Created attachment 117195 [details]
Proposed patch

Added JavadocTestForClass054-056
Comment 11 Philipe Mulet CLA 2008-11-06 09:09:03 EST
Re: comment 7
Yes, this is what tricked me here. The patch addresses it.
Note that the behavior depends on compliance too. If >= 1.5, then presence of single type import allows member single name access.

Tom - how pressing is that in 3.4.x ? Can you wait until 3.5 ?
Comment 12 Philipe Mulet CLA 2008-11-06 09:10:44 EST
Released for 3.5M4.
Fixed
Comment 13 Thomas Schindl CLA 2008-11-06 09:16:47 EST
Not pressing at all, so 3.5 is fine. Thanks for the fast fixing.
Comment 14 Markus Keller CLA 2008-11-06 09:37:54 EST
> Note that the behavior depends on compliance too. If >= 1.5, then presence of
> single type import allows member single name access.

Which is against the Javadoc spec, but some sunny people don't seem to care :-(
Comment 15 Jerome Lanneluc CLA 2008-12-09 05:14:51 EST
Verified for 3.5M4 using I20081209-0100