Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 400902 - [1.8][search] Search engine fails to annotation matches in extends/implements clauses.
Summary: [1.8][search] Search engine fails to annotation matches in extends/implements...
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.3   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: BETA J8   Edit
Assignee: Manoj N Palat CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 400899
  Show dependency tree
 
Reported: 2013-02-15 05:04 EST by Srikanth Sankaran CLA
Modified: 2013-02-27 12:06 EST (History)
1 user (show)

See Also:
srikanth_sankaran: review+


Attachments
Work-In-Progress Patch (1.95 KB, patch)
2013-02-20 21:06 EST, Manoj N Palat CLA
no flags Details | Diff
Proposed Patch (4.57 KB, patch)
2013-02-27 09:34 EST, Manoj N Palat CLA
no flags Details | Diff
Proposed Patch (4.51 KB, patch)
2013-02-27 09:39 EST, Manoj N Palat CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Srikanth Sankaran CLA 2013-02-15 05:04:22 EST
BETA_JAVA8:

// ---------

import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import java.io.Serializable;

public class X extends @Marker Object implements @Marker Serializable {
	int x = (@Marker int) 0;
}

@Target(ElementType.TYPE_USE)	
@interface Marker {
	
}
// ------------------------


Searching for references to Marker brings up only one result - the one
inside the cast. The other two are missing.
Comment 1 Manoj N Palat CLA 2013-02-20 21:06:14 EST
Created attachment 227378 [details]
Work-In-Progress Patch
Comment 2 Manoj N Palat CLA 2013-02-27 09:34:47 EST
Created attachment 227670 [details]
Proposed Patch
Comment 3 Manoj N Palat CLA 2013-02-27 09:39:54 EST
Created attachment 227671 [details]
Proposed Patch

corrected patch (comments removed)
Comment 4 Srikanth Sankaran CLA 2013-02-27 12:04:06 EST
Fix looks good. I made a few changes:

(1) JCP disclaimer is missing in both files - fixed.
(2) I moved the fix to down below - this eliminates the need for various
null checks
(3) We should always extract array length computation outside of the for
loop's condition as it is invariant.
(4) Since the for loop's index variable's scope is limited to the for loop,
we can reuse the same variable i as the index in the second loop - i as the
index variable is lot less distracting, the moment we see j, it conjures up
the notion of a nested loop which is not the case here.
(5) When fixing a method, it helps to just eyeball the neighborhood of the
change - We are missing reporting of annotations on type variables of a class.
I'll raise a separate bug for that.

Fix and tests released here: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=4005c370e6cbaf5fe897eaa7c9410e92ff25148d

Thanks Manoj.
Comment 5 Srikanth Sankaran CLA 2013-02-27 12:06:03 EST
(In reply to comment #4)
> (5) When fixing a method, it helps to just eyeball the neighborhood of the
> change - We are missing reporting of annotations on type variables of a
> class.
> I'll raise a separate bug for that.

This is already there: https://bugs.eclipse.org/bugs/show_bug.cgi?id=400919