]> source.dussan.org Git - aspectj.git/commitdiff
see pr112105 comment #13: improved (slightly) code for locating annotation holders.
authoraclement <aclement>
Wed, 26 Oct 2005 16:49:53 +0000 (16:49 +0000)
committeraclement <aclement>
Wed, 26 Oct 2005 16:49:53 +0000 (16:49 +0000)
weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java

index 97401295fccfc08d7bab3bbc119a9bbb0bbb746e..f4cb5ab3230d219a163e1f2d2923d6771ad5d030 100644 (file)
@@ -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.
         * <b>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());