Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 85570 Details for
Bug 212834
[dom] IMethodBinding.getParameterAnnotations does not return annotations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
v00.txt (text/plain), 12.69 KB, created by
Frederic Fusier
on 2007-12-19 10:56:08 EST
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2007-12-19 10:56:08 EST
Size:
12.69 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java,v >retrieving revision 1.151 >diff -u -r1.151 SourceTypeBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 28 Sep 2007 18:26:06 -0000 1.151 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 19 Dec 2007 15:33:02 -0000 >@@ -1360,6 +1360,9 @@ > TypeBinding[] newParameters = new TypeBinding[size]; > for (int i = 0; i < size; i++) { > Argument arg = arguments[i]; >+ if (arg.annotations != null) { >+ method.tagBits |= TagBits.HasParameterAnnotations; >+ } > TypeBinding parameterType = arg.type.resolveType(methodDecl.scope, true /* check bounds*/); > if (parameterType == null) { > foundArgProblem = true; >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java,v >retrieving revision 1.94 >diff -u -r1.94 MethodBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java 24 Sep 2007 22:49:54 -0000 1.94 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java 19 Dec 2007 15:33:01 -0000 >@@ -14,6 +14,7 @@ > import org.eclipse.jdt.internal.compiler.ClassFile; > import org.eclipse.jdt.internal.compiler.ast.ASTNode; > import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; >+import org.eclipse.jdt.internal.compiler.ast.Argument; > import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > import org.eclipse.jdt.internal.compiler.codegen.ConstantPool; >@@ -442,7 +443,35 @@ > public AnnotationBinding[] getParameterAnnotations(int index) { > MethodBinding originalMethod = this.original(); > AnnotationHolder holder = originalMethod.declaringClass.retrieveAnnotationHolder(originalMethod, true); >- return holder == null ? Binding.NO_ANNOTATIONS : holder.getParameterAnnotations(index); >+ AnnotationBinding[][] allParameterAnnotations = holder == null ? null : holder.getParameterAnnotations(); >+ if (allParameterAnnotations == null && (this.tagBits & TagBits.HasParameterAnnotations) != 0) { >+ // forward reference to method, where param annotations have not yet been associated to method >+ if (this.declaringClass instanceof SourceTypeBinding) { >+ SourceTypeBinding sourceType = (SourceTypeBinding) this.declaringClass; >+ if (sourceType.scope != null) { >+ AbstractMethodDeclaration methodDecl = sourceType.scope.referenceType().declarationOf(this); >+ if (methodDecl.arguments != null) { >+ for (int i = 0, length = methodDecl.arguments.length; i < length; i++) { >+ Argument argument = methodDecl.arguments[i]; >+ if (argument.annotations != null) { >+ ASTNode.resolveAnnotations(methodDecl.scope, argument.annotations, argument.binding); >+ if (allParameterAnnotations == null) { >+ allParameterAnnotations = new AnnotationBinding[length][]; >+ } >+ allParameterAnnotations[i] = argument.binding.getAnnotations(); >+ } >+ } >+ if (allParameterAnnotations != null) >+ this.setParameterAnnotations(allParameterAnnotations); >+ } >+ } >+ } >+ } >+ AnnotationBinding[] resultParameterAnnotations = allParameterAnnotations == null ? null : allParameterAnnotations[ index]; >+ if (resultParameterAnnotations != null) { >+ return resultParameterAnnotations; >+ } >+ return Binding.NO_ANNOTATIONS; > } > public final int getAccessFlags() { > return modifiers & ExtraCompilerModifiers.AccJustFlag; >Index: dom/org/eclipse/jdt/core/dom/AnnotationBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AnnotationBinding.java,v >retrieving revision 1.5 >diff -u -r1.5 AnnotationBinding.java >--- dom/org/eclipse/jdt/core/dom/AnnotationBinding.java 24 Oct 2007 13:50:52 -0000 1.5 >+++ dom/org/eclipse/jdt/core/dom/AnnotationBinding.java 19 Dec 2007 15:33:02 -0000 >@@ -128,6 +128,10 @@ > if (!(this.bindingResolver instanceof DefaultBindingResolver)) return ""; //$NON-NLS-1$ > DefaultBindingResolver resolver = (DefaultBindingResolver) this.bindingResolver; > ASTNode node = (ASTNode) resolver.bindingsToAstNodes.get(this); >+ if (node == null) { >+ // Can happen if annotation bindings have been resolved before having parsed the declaration >+ return ""; //$NON-NLS-1$ >+ } > ASTNode recipient = node.getParent(); > switch (recipient.getNodeType()) { > case ASTNode.PACKAGE_DECLARATION: >Index: compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java,v >retrieving revision 1.96 >diff -u -r1.96 AbstractMethodDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java 21 Nov 2007 11:13:48 -0000 1.96 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java 19 Dec 2007 15:33:01 -0000 >@@ -90,7 +90,6 @@ > Argument argument = this.arguments[i]; > argument.bind(this.scope, this.binding.parameters[i], used); > if (argument.annotations != null) { >- this.binding.tagBits |= TagBits.HasParameterAnnotations; > if (paramAnnotations == null) > paramAnnotations = new AnnotationBinding[length][]; > paramAnnotations[i] = argument.binding.getAnnotations(); >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java,v >retrieving revision 1.196 >diff -u -r1.196 AbstractJavaModelTests.java >--- src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 18 Dec 2007 16:32:55 -0000 1.196 >+++ src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 19 Dec 2007 15:33:03 -0000 >@@ -1796,9 +1796,9 @@ > ICompilationUnit wc = getWorkingCopy(path, source, this.wcOwner); > // Verify that compute problem parameter is compatible with working copy problem requestor > if (computeProblems) { >- assertNotNull("Cannot compute problems if working copy owner is set to null!", this.wcOwner.getProblemRequestor(wc)); >+ assertNotNull("Cannot compute problems if the problem requestor of the working copy owner is set to null!", this.wcOwner.getProblemRequestor(wc)); > } else { >- assertNull("Cannot ignore problems if working copy owner is not set to null!", this.wcOwner.getProblemRequestor(wc)); >+ assertNull("Cannot ignore problems if the problem requestor of the working copy owner is not set to null!", this.wcOwner.getProblemRequestor(wc)); > } > return wc; > } >Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTest.java,v >retrieving revision 1.2 >diff -u -r1.2 ASTConverterBugsTest.java >--- src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTest.java 18 Dec 2007 10:51:45 -0000 1.2 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTest.java 19 Dec 2007 15:33:03 -0000 >@@ -19,14 +19,15 @@ > import org.eclipse.jdt.core.IClassFile; > import org.eclipse.jdt.core.ICompilationUnit; > import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.core.WorkingCopyOwner; > import org.eclipse.jdt.core.dom.*; > > public class ASTConverterBugsTest extends ConverterTestSetup { > > public void setUpSuite() throws Exception { >- PROJECT_SETUP = true; // do not copy Converter* directories >+// PROJECT_SETUP = true; // do not copy Converter* directories > super.setUpSuite(); >- setUpJCLClasspathVariables("1.5"); >+// setUpJCLClasspathVariables("1.5"); > waitUntilIndexesReady(); > } > >@@ -75,9 +76,18 @@ > parser.setResolveBindings(resolveBindings); > parser.setStatementsRecovery(statementsRecovery); > parser.setBindingsRecovery(bindingsRecovery); >+ parser.setWorkingCopyOwner(this.wcOwner); > return parser.createAST(null); > } > >+protected void resolveASTs(ICompilationUnit[] cus, String[] bindingKeys, ASTRequestor requestor, IJavaProject project, WorkingCopyOwner owner) { >+ ASTParser parser = createASTParser(); >+ parser.setResolveBindings(true); >+ parser.setProject(project); >+ parser.setWorkingCopyOwner(owner); >+ parser.createASTs(cus, bindingKeys, requestor, null); >+} >+ > /** > * @bug 186410: [dom] StackOverflowError due to endless superclass bindings hierarchy > * @test Ensures that the superclass of "java.lang.Object" class is null even when it's a recovered binding >@@ -203,6 +213,46 @@ > } > > /** >+ * @bug 212834: [dom] IMethodBinding.getParameterAnnotations does not return annotations >+ * @test Ensures that the method binding get the parameter annotations even on method invocation >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=212834" >+ */ >+public void testBug212834() throws CoreException, IOException { >+ workingCopies = new ICompilationUnit[3]; >+ workingCopies[0] = getWorkingCopy("/Converter15/src/Baz.java", >+ "public @interface Baz {\n" + >+ "}\n" >+ ); >+ workingCopies[1] = getWorkingCopy("/Converter15/src/C.java", >+ "public class C {\n" + >+ "public C(D d) {\n" + >+ " foo(5);\n" + >+ " d.bar(7);\n" + >+ "}\n" + >+ "@Baz\n" + >+ "public void foo(@Baz int x) { }\n" + >+ "\n" + >+ "}" >+ ); >+ workingCopies[2] = getWorkingCopy("/Converter15/src/D.java", >+ "public class D {\n" + >+ "@Baz\n" + >+ "public void bar(@Baz int y) { }\n" + >+ "\n" + >+ "}" >+ ); >+ >+ CompilationUnit unit = (CompilationUnit) runConversion(workingCopies[1], true, false, true); >+ MethodDeclaration methodDeclaration = (MethodDeclaration) getASTNode(unit, 0, 0); >+ MethodInvocation methodInvocation = (MethodInvocation) ((ExpressionStatement) methodDeclaration.getBody().statements().get(1)).getExpression(); >+ IMethodBinding methodBinding = methodInvocation.resolveMethodBinding(); >+ assertBindingsEqual(methodInvocation+" has invalid parameter annotations!", >+ "@LBaz;", >+ methodBinding.getParameterAnnotations(0) >+ ); >+} >+ >+/** > * @bug 212857: [dom] AST has wrong source range after parameter with array-valued annotation > * @test Ensures that the method body has the right source range even when there's braces in its header > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=212857" >@@ -210,11 +260,11 @@ > public void testBug212857() throws CoreException, IOException { > workingCopies = new ICompilationUnit[1]; > String source = "package xy;\n" + >- "public class C {\n" + >- " void m(@SuppressWarnings({\"unused\", \"bla\"}) int arg) {\n" + >- " int local;\n" + >- " }\n" + >- "}\n"; >+ "public class C {\n" + >+ " void m(@SuppressWarnings({\"unused\", \"bla\"}) int arg) {\n" + >+ " int local;\n" + >+ " }\n" + >+ "}\n"; > workingCopies[0] = getWorkingCopy("/Converter15/src/xy/C.java", source); > CompilationUnit unit = (CompilationUnit) runConversion(workingCopies[0], true, false, true); > MethodDeclaration methodDeclaration = (MethodDeclaration) getASTNode(unit, 0, 0); >Index: src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java,v >retrieving revision 1.35 >diff -u -r1.35 AbstractASTTests.java >--- src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java 27 Nov 2007 09:47:51 -0000 1.35 >+++ src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java 19 Dec 2007 15:33:03 -0000 >@@ -207,6 +207,10 @@ > } > > protected void assertBindingsEqual(String expected, IBinding[] actualBindings) { >+ assertBindingsEqual("Unexpected bindings", expected, actualBindings); >+ } >+ >+ protected void assertBindingsEqual(String message, String expected, IBinding[] actualBindings) { > StringBuffer buffer = new StringBuffer(); > for (int i = 0, length = actualBindings.length; i < length; i++) { > if (i > 0) buffer.append('\n'); >@@ -220,10 +224,7 @@ > System.out.print(displayString(actual, 3)); > System.out.println(','); > } >- assertEquals( >- "Unexpected bindings", >- expected, >- actual); >+ assertEquals(message, expected, actual); > } > > /*
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 212834
: 85570