From: aclement Date: Wed, 26 Oct 2005 16:49:53 +0000 (+0000) Subject: see pr112105 comment #13: improved (slightly) code for locating annotation holders. X-Git-Tag: V1_5_0RC1~307 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=62b26e16ff7a228d451986cfb6df20f9f008cfca;p=aspectj.git see pr112105 comment #13: improved (slightly) code for locating annotation holders. --- diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java index 97401295f..f4cb5ab32 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java @@ -1628,6 +1628,20 @@ class BcelClassWeaver implements IClassWeaver { } } + /** + * For some named resolved type, this method looks for a member with a particular name - + * it should only be used when you truly believe there is only one member with that + * name in the type as it returns the first one it finds. + */ + private ResolvedMember findResolvedMemberNamed(ResolvedType type,String methodName) { + ResolvedMember[] allMethods = type.getDeclaredMethods(); + for (int i = 0; i < allMethods.length; i++) { + ResolvedMember member = allMethods[i]; + if (member.getName().equals(methodName)) return member; + } + return null; + } + /** * For a given resolvedmember, this will discover the real annotations for it. * Should only be used when the resolvedmember is the contents of an effective signature @@ -1657,13 +1671,14 @@ class BcelClassWeaver implements IClassWeaver { ResolvedMember resolvedDooberry = world.resolve(declaredSig); annotations = resolvedDooberry.getAnnotationTypes(); } else { - ResolvedMember realthing = AjcMemberMaker.interMethodDispatcher(rm.resolve(world),memberHostType); - ResolvedMember resolvedDooberry = world.resolve(realthing); + ResolvedMember realthing = AjcMemberMaker.interMethodDispatcher(rm.resolve(world),memberHostType).resolve(world); + // ResolvedMember resolvedDooberry = world.resolve(realthing); + ResolvedMember theRealMember = findResolvedMemberNamed(memberHostType.resolve(world),realthing.getName()); // AMC temp guard for M4 - if (resolvedDooberry == null) { + if (theRealMember == null) { throw new UnsupportedOperationException("Known limitation in M4 - can't find ITD members when type variable is used as an argument and has upper bound specified"); } - annotations = resolvedDooberry.getAnnotationTypes(); + annotations = theRealMember.getAnnotationTypes(); } } else if (rm.getKind()==Member.CONSTRUCTOR) { ResolvedMember realThing = AjcMemberMaker.postIntroducedConstructor(memberHostType.resolve(world),rm.getDeclaringType(),rm.getParameterTypes());