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

Bug 474038

Summary: Wrongly reports addition of first type parameter to a generic method
Product: [Eclipse Project] PDE Reporter: Markus Keller <markus.kell.r>
Component: API ToolsAssignee: Markus Keller <markus.kell.r>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, Lars.Vogel, markus.kell.r, Vikas.Chandra
Version: 4.6Flags: Vikas.Chandra: review+
Target Milestone: 4.6 M2   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/52960
https://git.eclipse.org/c/pde/eclipse.pde.ui.git/commit/?id=4f5169287422584658daa624ce779ba77b45c5c7
Whiteboard:
Bug Depends on:    
Bug Blocks: 465292    

Description Markus Keller CLA 2015-07-31 09:49:18 EDT
Bug 465292 revealed an example of a binary-compatible, but source-incompatible API change.

Example:

public interface Test {
	public void move(Number n, List<Number> l);
}

Change to:

public interface Test {
	public <T extends Number> void move(T n, List<T> l);
}

Since the erasure didn't change, this is a binary-compatible change. However, an implementation or extension of the interface that already used the List<Number> parameter type won't compile any more after the change. (If it used the raw type List, then would still compile.)

Since API Tools are only concerned about binary-incompatible changes, this change should not result in an error.

Fix follows.
Comment 1 Eclipse Genie CLA 2015-07-31 09:51:24 EDT
New Gerrit change created: https://git.eclipse.org/r/52960
Comment 2 Markus Keller CLA 2015-07-31 10:35:15 EDT
The main fix is in ClassFileComparator line 676, where the compatible IDelta.TYPE_PARAMETERS flag is used instead of IDelta.TYPE_PARAMETER. The latter is correctly reported as error in DeltaProcessor#isMethodCompatible(IDelta).

The other changes in ClassFileComparator fix the IDelta#getKey() for methods. element1.getName() is not a correct key, which resulted in problem markers with wrong source ranges ([-1, 1]) for the errors in bug 465292. To see this part of the fix in action, e.g. apply this incompatible addition of a second type parameter to  org.eclipse.e4.ui.workbench.modeling.EModelService:

Old:
	public <T> List<T> findElements(MUIElement searchRoot,
			String id, Class<T> clazz, List<String> tagsToMatch);

New:
	public <T, M extends MUIElement> List<T> findElements(M searchRoot,
			String id, Class<T> clazz, List<String> tagsToMatch);
Comment 3 Vikas Chandra CLA 2015-09-11 07:40:20 EDT
Fix works fine and all test case passes. Can you update the license year before committing.
Comment 5 Lars Vogel CLA 2015-09-11 10:40:02 EDT
Thanks Markus. @Vikas, I updated the copyright headers for Markus.
Comment 6 Vikas Chandra CLA 2015-09-15 04:46:48 EDT
verified in 
Version: Neon (4.6)
Build id: I20150914-2000