Bug 213509 - [dom] IMethodBinding.getParameterAnnotations returns annotations for wrong parameter
Summary: [dom] IMethodBinding.getParameterAnnotations returns annotations for wrong pa...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M5   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 217793 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-12-19 13:57 EST by Kevin CLA
Modified: 2008-02-05 05:20 EST (History)
2 users (show)

See Also:


Attachments
Proposed patch (10.32 KB, patch)
2007-12-20 10:13 EST, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin CLA 2007-12-19 13:57:57 EST
Build ID: N/A (Eclipse 3.3)

Steps To Reproduce:
1. Create a test method with two formal parameters with different annotations.
2. Acquire a org.eclipse.jdt.core.dom.IMethodBinding for this method from a MethodCall AST node calling this method.
3. Call getParameterAnnotations(0) and getParameterAnnotations(1) in sequence.  

The same array of annotations with be returned both times, containing the annotation bindings for the first parameter of the method.  Instead, the second call should return annotation bindings for the second parameter.

More information:
A suitable test method might have the signature:

void m(@Foo a, @Bar b)

Calling getParameterAnnotations(0) and getParameterAnnotations(1) on an org.eclipse.jdt.core.dom.IMethodBinding for this method will return a IAnnotationBinding for @Foo both times instead of returning a IAnnotationBinding for @Bar from getParameterAnnotations(1).

Using the debugger it appears that the implementation of getParameterAnnotations caches the result from the first call and returns the cached result regardless of the index passed in subsequent calls.

This problem does not exist in Eclipse 3.2.1 (build M20060921-0945).

This problem is different from Eclipse bug #212834 and does not seem to depend on whether the method is declared and called in the same or different compilation units.  

It is unknown whether the bug also occurs when using a IMethodBinding retrieved from the MethodDeclaration AST node for a method; the problem was observed when using a IMethodBinding from a MethodCall AST node.
Comment 1 Frederic Fusier CLA 2007-12-20 10:13:09 EST
Created attachment 85654 [details]
Proposed patch
Comment 2 Frederic Fusier CLA 2007-12-20 10:18:42 EST
Released for 3.4M5 in HEAD stream.
Comment 3 Frederic Fusier CLA 2008-02-05 04:20:50 EST
*** Bug 217793 has been marked as a duplicate of this bug. ***
Comment 4 David Audel CLA 2008-02-05 05:20:35 EST
Verified for 3.4M5 using build I20080204-0010.