]> source.dussan.org Git - aspectj.git/commitdiff
345172
authoraclement <aclement>
Thu, 12 May 2011 19:55:28 +0000 (19:55 +0000)
committeraclement <aclement>
Thu, 12 May 2011 19:55:28 +0000 (19:55 +0000)
weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java

index 57fb89a977cb19b366747a7902e2a28f4cda19d2..eb8597925f6405b3cd248c1b0a599b8289bb373d 100644 (file)
@@ -2902,26 +2902,39 @@ class BcelClassWeaver implements IClassWeaver {
         * 
         * @param type the type to search for the member
         * @param methodName the name of the method to find
-        * @param Class[] the method parameters that the discovered method should have
+        * @param params the method parameters that the discovered method should have
         */
        private ResolvedMember findResolvedMemberNamed(ResolvedType type, String methodName, UnresolvedType[] params) {
                ResolvedMember[] allMethods = type.getDeclaredMethods();
+               List<ResolvedMember> candidates = new ArrayList<ResolvedMember>();
                for (int i = 0; i < allMethods.length; i++) {
                        ResolvedMember candidate = allMethods[i];
                        if (candidate.getName().equals(methodName)) {
+                               if (candidate.getArity() == params.length) {
+                                       candidates.add(candidate);
+                               }
+                       }
+               }
+
+               if (candidates.size() == 0) {
+                       return null;
+               } else if (candidates.size() == 1) {
+                       return candidates.get(0);
+               } else {
+                       // multiple candidates
+                       for (ResolvedMember candidate : candidates) {
+                               // These checks will break down with generics... but that would need two ITDs with the same name, same arity and
+                               // generics
+                               boolean allOK = true;
                                UnresolvedType[] candidateParams = candidate.getParameterTypes();
-                               if (candidateParams.length == params.length) {
-                                       // boolean allOK = true; // this checking all breaks down with generics in the mix, unfortunately, dont have
-                                       // time to fix it up right now
-                                       // for (int p = 0; p < candidateParams.length; p++) {
-                                       // if (!candidateParams[p].getErasureSignature().equals(params[p].getErasureSignature())) {
-                                       // allOK = false;
-                                       // break;
-                                       // }
-                                       // }
-                                       // if (allOK) {
+                               for (int p = 0; p < candidateParams.length; p++) {
+                                       if (!candidateParams[p].getErasureSignature().equals(params[p].getErasureSignature())) {
+                                               allOK = false;
+                                               break;
+                                       }
+                               }
+                               if (allOK) {
                                        return candidate;
-                                       // }
                                }
                        }
                }