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 86417 Details for
Bug 214647
[dom] NPE in MethodBinding.getParameterAnnotations(..)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
New proposed patch
v00.txt (text/plain), 5.60 KB, created by
Frederic Fusier
on 2008-01-08 13:53:43 EST
(
hide
)
Description:
New proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2008-01-08 13:53:43 EST
Size:
5.60 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >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.96 >diff -u -r1.96 MethodBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java 20 Dec 2007 15:18:04 -0000 1.96 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java 8 Jan 2008 18:49:21 -0000 >@@ -447,21 +447,26 @@ > MethodBinding originalMethod = this.original(); > AnnotationHolder holder = originalMethod.declaringClass.retrieveAnnotationHolder(originalMethod, true); > AnnotationBinding[][] allParameterAnnotations = holder == null ? null : holder.getParameterAnnotations(); >- if (allParameterAnnotations == null && (this.tagBits & TagBits.HasParameterAnnotations) != 0) { >+ if (allParameterAnnotations == null) { > allParameterAnnotations = new AnnotationBinding[length][]; >- // 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); >- for (int i = 0; i < length; i++) { >- Argument argument = methodDecl.arguments[i]; >- if (argument.annotations != null) { >- ASTNode.resolveAnnotations(methodDecl.scope, argument.annotations, argument.binding); >- allParameterAnnotations[i] = argument.binding.getAnnotations(); >+ if ((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); >+ for (int i = 0; i < length; i++) { >+ Argument argument = methodDecl.arguments[i]; >+ if (argument.annotations != null) { >+ ASTNode.resolveAnnotations(methodDecl.scope, argument.annotations, argument.binding); >+ allParameterAnnotations[i] = argument.binding.getAnnotations(); >+ } >+ } >+ } else { >+ for (int i = 0; i < length; i++) { >+ allParameterAnnotations[i] = Binding.NO_ANNOTATIONS; > } > } >- this.setParameterAnnotations(allParameterAnnotations); > } else { > for (int i = 0; i < length; i++) { > allParameterAnnotations[i] = Binding.NO_ANNOTATIONS; >@@ -472,6 +477,7 @@ > allParameterAnnotations[i] = Binding.NO_ANNOTATIONS; > } > } >+ this.setParameterAnnotations(allParameterAnnotations); > } > return allParameterAnnotations; > } >#P org.eclipse.jdt.core.tests.model >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.5 >diff -u -r1.5 ASTConverterBugsTest.java >--- src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTest.java 31 Dec 2007 13:33:03 -0000 1.5 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTest.java 8 Jan 2008 18:49:24 -0000 >@@ -40,7 +40,8 @@ > } > > protected void checkParameterAnnotations(String message, String expected, IMethodBinding methodBinding) { >- int size = methodBinding.getParameterTypes().length; >+ ITypeBinding[] parameterTypes = methodBinding.getParameterTypes(); >+ int size = parameterTypes == null ? 0 : parameterTypes.length; > StringBuffer buffer = new StringBuffer(); > for (int i=0; i<size; i++) { > buffer.append("----- param "); >@@ -497,4 +498,42 @@ > methodDeclaration.resolveBinding() > ); > } >+ >+/** >+ * @bug 214647: [dom] NPE in MethodBinding.getParameterAnnotations(..) >+ * @test Ensures that no NPE occurs when parameters have no annotation >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=214647" >+ */ >+public void testBug214647() throws CoreException, IOException { >+ workingCopies = new ICompilationUnit[1]; >+ workingCopies[0] = getWorkingCopy("/Converter15/src/Test.java", >+ "public class Test {\n" + >+ " void m(String str) {}\n" + >+ "}\n" >+ ); >+ >+ CompilationUnit unit = (CompilationUnit) runConversion(workingCopies[0], true/*bindings*/, false/*no statement recovery*/, true/*bindings recovery*/); >+ MethodDeclaration methodDeclaration = (MethodDeclaration) getASTNode(unit, 0, 0); >+ checkParameterAnnotations(methodDeclaration+" has invalid parameter annotations!", >+ "----- param 1-----\n", >+ methodDeclaration.resolveBinding() >+ ); >+} >+public void testBug214647b() throws CoreException, IOException { >+ workingCopies = new ICompilationUnit[1]; >+ workingCopies[0] = getWorkingCopy("/Converter15/src/Test.java", >+ "public class Test {\n" + >+ " void m(String str, Object o, int x) {}\n" + >+ "}\n" >+ ); >+ >+ CompilationUnit unit = (CompilationUnit) runConversion(workingCopies[0], true/*bindings*/, false/*no statement recovery*/, true/*bindings recovery*/); >+ MethodDeclaration methodDeclaration = (MethodDeclaration) getASTNode(unit, 0, 0); >+ checkParameterAnnotations(methodDeclaration+" has invalid parameter annotations!", >+ "----- param 1-----\n" + >+ "----- param 2-----\n" + >+ "----- param 3-----\n", >+ methodDeclaration.resolveBinding() >+ ); >+} > }
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 214647
:
86415
|
86417