diff options
author | aclement <aclement> | 2006-10-23 11:55:54 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-10-23 11:55:54 +0000 |
commit | 757004ca6702a97369aac2ba62532f13ac5ced36 (patch) | |
tree | e64c1d3a4e7463dc592f9959109633719e7d0165 /weaver | |
parent | efe6cc79c4c19ebc8f7109f10220b13dc4efffad (diff) | |
download | aspectj-757004ca6702a97369aac2ba62532f13ac5ced36.tar.gz aspectj-757004ca6702a97369aac2ba62532f13ac5ced36.zip |
tests and fix for 149908: NPE in org.aspectj.weaver.MemberImpl.getModifiers
Diffstat (limited to 'weaver')
-rw-r--r-- | weaver/src/org/aspectj/weaver/MemberImpl.java | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/weaver/src/org/aspectj/weaver/MemberImpl.java b/weaver/src/org/aspectj/weaver/MemberImpl.java index 469a4b864..cad1e78e0 100644 --- a/weaver/src/org/aspectj/weaver/MemberImpl.java +++ b/weaver/src/org/aspectj/weaver/MemberImpl.java @@ -31,6 +31,9 @@ public class MemberImpl implements Comparable, AnnotatedElement,Member { protected UnresolvedType[] parameterTypes; private final String signature; private String paramSignature; + private boolean reportedCantFindDeclaringType = false; + private boolean reportedUnresolvableMember = false; + /** * All the signatures that a join point with this member as its signature has. @@ -523,14 +526,24 @@ public class MemberImpl implements Comparable, AnnotatedElement,Member { * @see org.aspectj.weaver.Member#getModifiers(org.aspectj.weaver.World) */ public int getModifiers(World world) { - return resolve(world).getModifiers(); + ResolvedMember resolved = resolve(world); + if (resolved == null) { + reportDidntFindMember(world); + return 0; + } + return resolved.getModifiers(); } /* (non-Javadoc) * @see org.aspectj.weaver.Member#getExceptions(org.aspectj.weaver.World) */ public UnresolvedType[] getExceptions(World world) { - return resolve(world).getExceptions(); + ResolvedMember resolved = resolve(world); + if (resolved == null) { + reportDidntFindMember(world); + return UnresolvedType.NONE; + } + return resolved.getExceptions(); } /* (non-Javadoc) @@ -932,7 +945,12 @@ public class MemberImpl implements Comparable, AnnotatedElement,Member { * @see org.aspectj.weaver.Member#getParameterNames(org.aspectj.weaver.World) */ public String[] getParameterNames(World world) { - return resolve(world).getParameterNames(); + ResolvedMember resolved = resolve(world); + if (resolved == null) { + reportDidntFindMember(world); + return null; + } + return resolved.getParameterNames(); } /** @@ -946,5 +964,22 @@ public class MemberImpl implements Comparable, AnnotatedElement,Member { return joinPointSignatures; } + /** + * Raises an [Xlint:cantFindType] message if the declaring type + * cannot be found or an [Xlint:unresolvableMember] message if the + * type can be found (bug 149908) + */ + private void reportDidntFindMember(World world) { + if (reportedCantFindDeclaringType || reportedUnresolvableMember) return; + ResolvedType rType = getDeclaringType().resolve(world); + if (rType.isMissing()) { + world.getLint().cantFindType.signal(WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE,rType.getName()),null); + reportedCantFindDeclaringType = true; + } else { + world.getLint().unresolvableMember.signal(getName(),null); + reportedUnresolvableMember = true; + } + } + } |