Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 341789

Summary: Warning on Javadoc @see when referencing generic method with multiple bounds
Product: [Eclipse Project] JDT Reporter: Mauro Molinari <mauromol>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: markus.kell.r, Olivier_Thomann, zorzella
Version: 3.6.2Keywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard: stalebug

Description Mauro Molinari CLA 2011-04-04 10:35:48 EDT
Build Identifier: M20110210-1200

See steps to repro

Reproducible: Always

Steps to Reproduce:
1. write the following classes:

public interface A
{
	/**
	 * @see #setaMethod(B)
	 */
	<T extends B & C> T getaMethod();

	/**
	 * @see #getaMethod()
	 */
	<T extends B & C> void setaMethod(T param);
}

public class B
{
}

public interface C
{
}

2. look at the rows where I use @see in the Javadoc; this is what I see:

- on the first @see in A:
Javadoc: Bound mismatch: The generic method setaMethod(T) of type A is not applicable for the arguments (B). 
 The inferred type B is not a valid substitute for the bounded parameter <T extends B & C>

- on the second @see in A:

Javadoc: Bound mismatch: The generic method getaMethod() of type A is not applicable for the arguments (). 
 The inferred type B is not a valid substitute for the bounded parameter <T extends B & C>
Comment 1 Markus Keller CLA 2011-04-04 13:27:53 EDT
Reproduced in HEAD. You have to enable Javadoc processing for the project and enable "Malformed Javadoc comments" and "Validate tag arguments".
Comment 2 Olivier Thomann CLA 2011-04-04 13:49:56 EDT
This is the same issue. Once bug 341795 is fixed, this will also be fixed.

*** This bug has been marked as a duplicate of bug 341795 ***
Comment 3 Markus Keller CLA 2011-04-04 14:08:40 EDT
(In reply to comment #2)
> This is the same issue. Once bug 341795 is fixed, this will also be fixed.
> 
> *** This bug has been marked as a duplicate of bug 341795 ***

I'm not sure that's really the same issue. Javadoc references should use the erasure of the method parameter types, so no type inference should be necessary in that situation.
Comment 4 Olivier Thomann CLA 2011-04-04 14:24:30 EDT
(In reply to comment #3)
> I'm not sure that's really the same issue. Javadoc references should use the
> erasure of the method parameter types, so no type inference should be necessary
> in that situation.
If this is not the same issue, this will be reopened.
Comment 5 Mauro Molinari CLA 2014-07-28 03:50:28 EDT
This first warning still happens in Kepler and Luna.
Also, it is not Java7 specific (as bug 341795 would suggest).

By the way, I'm not certain whether the warning is wrong or the actual syntax of @see is wrong for this specific case, however it's the one produced by JDT code assist. Even if I searched on the net, I was not able to determine whether it's correct or not. I didn't try the Javadoc tool to see what it says.
Comment 6 Markus Keller CLA 2014-07-28 12:33:10 EDT
With master, I only get a single problem "Javadoc: The method setaMethod(T) in the type A is not applicable for the arguments (B)" on 

	 * @see #setaMethod(B)

This warning is wrong. http://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html still doesn't clearly specify this, but all evidence tells that the erasure of a type variable should be used (which is "B" here).

Javadoc.exe from JDK 8 also accepts the reference.

Interestingly, the bug vanishes once I turn "interface A" into "interface A<E>". I don't even have to declare method "void take(E e);" and a reference "@see #take(Object)" to prove the point...
Comment 7 Zorzella Mising name CLA 2017-09-05 14:51:57 EDT
Note that Ctrl-Clicking the method works properly, and that, unless there are overloads, it's possible to work around this issue by using the syntax with no params specified. Here's an annotated rundown of the issue:

************************************

public abstract class JavadocMultipleBoundsIssue {
  
  abstract <T extends CharSequence & Runnable> void foo(T t); 

  /**
   * This first one is what Eclipse's Ctrl-space completion proposes, but it
   * results in a "not applicable for the arguments" warning (note that
   * Ctrl-Clicking it works correctly):
   * 
   * See {@link #foo(CharSequence)}
   * 
   * This second one is "as valid" as the one Eclipse suggests, and it also
   * resutls in the analogous warning (note that Ctrl-Clicking it also works
   * correctly):
   * 
   * See {@link #foo(Runnable)}
   * 
   * This would be if one tried to use the entire string that defines the
   * multiple bounds. Now you end up with a "Invalid parameters declaration"
   * warning (note that Ctrl-Clicking it does not work at all):
   * 
   * See {@link #foo(CharSequence & Runnable)}
   * 
   * Finally, this actually works, but, of course, is not ideal, and would not
   * be an option if there were multiple overloads of {@code foo}.
   * 
   * See {@link #foo}
   */
  void bar() {}
  
}
Comment 8 Eclipse Genie CLA 2020-04-11 03:38:24 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.