diff options
author | aclement <aclement> | 2010-04-07 19:24:04 +0000 |
---|---|---|
committer | aclement <aclement> | 2010-04-07 19:24:04 +0000 |
commit | 94d0a4e9eabd5b1d807ae95418cda47a9d8f4371 (patch) | |
tree | 3b8cb8138f45ba9cb9d94486bf903b4ad890d668 /org.aspectj.ajdt.core/src | |
parent | 6014378077d97a3c235160dc210ab7e1e1a8f466 (diff) | |
download | aspectj-94d0a4e9eabd5b1d807ae95418cda47a9d8f4371.tar.gz aspectj-94d0a4e9eabd5b1d807ae95418cda47a9d8f4371.zip |
308386
Diffstat (limited to 'org.aspectj.ajdt.core/src')
-rw-r--r-- | org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseResolvedMember.java | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseResolvedMember.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseResolvedMember.java index 21df3705e..82d243f03 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseResolvedMember.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseResolvedMember.java @@ -30,6 +30,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifie import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding; import org.aspectj.weaver.AnnotationAJ; import org.aspectj.weaver.BCException; import org.aspectj.weaver.MemberKind; @@ -159,7 +160,17 @@ public class EclipseResolvedMember extends ResolvedMemberImpl { cachedAnnotationTypes = new ResolvedType[annos.length]; for (int i = 0; i < annos.length; i++) { Annotation type = annos[i]; - cachedAnnotationTypes[i] = w.resolve(UnresolvedType.forSignature(new String(type.resolvedType.signature()))); + TypeBinding typebinding = type.resolvedType; + // If there was a problem resolving the annotation (the import couldn't be found) then that can manifest + // here as typebinding == null. Normally errors are reported prior to weaving (so weaving is avoided and + // the null is not encountered) but the use of hasfield/hasmethod can cause early attempts to look at + // annotations and if we NPE here then the real error will not get reported. + if (typebinding == null) { + // Give up now - expect proper error to be reported + cachedAnnotationTypes = ResolvedType.EMPTY_RESOLVED_TYPE_ARRAY; + return cachedAnnotationTypes; + } + cachedAnnotationTypes[i] = w.resolve(UnresolvedType.forSignature(new String(typebinding.signature()))); } } } @@ -210,18 +221,18 @@ public class EclipseResolvedMember extends ResolvedMemberImpl { // Grab the set of bindings with matching selector MethodBinding[] mb = ((MethodBinding) realBinding).declaringClass.getMethods(methodBinding.selector); - if (mb!=null) { - for (int m = 0, max = mb.length; m < max; m++) { - MethodBinding candidate = mb[m]; - if (candidate instanceof InterTypeMethodBinding) { - if (InterTypeMemberFinder.matches(mb[m], methodBinding)) { - InterTypeMethodBinding intertypeMethodBinding = (InterTypeMethodBinding) candidate; - Annotation[] annos = intertypeMethodBinding.sourceMethod.annotations; - return annos; + if (mb != null) { + for (int m = 0, max = mb.length; m < max; m++) { + MethodBinding candidate = mb[m]; + if (candidate instanceof InterTypeMethodBinding) { + if (InterTypeMemberFinder.matches(mb[m], methodBinding)) { + InterTypeMethodBinding intertypeMethodBinding = (InterTypeMethodBinding) candidate; + Annotation[] annos = intertypeMethodBinding.sourceMethod.annotations; + return annos; + } } } } - } return null; // give up! kind of assuming here that the code has other problems (and they will be reported) } return methodDecl.annotations; |