From fadf06e67932195f5e14f550cb12e36356d20ba2 Mon Sep 17 00:00:00 2001 From: aclement Date: Thu, 12 May 2011 19:55:28 +0000 Subject: [PATCH] 345172 --- .../aspectj/weaver/bcel/BcelClassWeaver.java | 37 +++++++++++++------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java index 57fb89a97..eb8597925 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java @@ -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 candidates = new ArrayList(); 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; - // } } } } -- 2.39.5