From 39b577866fda7b892a0d192282fcd6a12ef7d070 Mon Sep 17 00:00:00 2001 From: acolyer Date: Wed, 14 Dec 2005 07:21:23 +0000 Subject: [PATCH] ensure we don't re-attempt modifier matching when walking up the signature hierarchy --- .../weaver/patterns/SignaturePattern.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java b/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java index 9515ec8cc..1e9369666 100644 --- a/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java @@ -281,16 +281,18 @@ public class SignaturePattern extends PatternNode { if (kind == Member.ADVICE) return true; // do the hard work then... + boolean subjectMatch = true; Iterator candidateMatches = joinPointSignature.getJoinPointSignatures(world); while(candidateMatches.hasNext()) { JoinPointSignature aSig = (JoinPointSignature) candidateMatches.next(); - FuzzyBoolean matchResult = matchesExactly(aSig,world,allowBridgeMethods); + FuzzyBoolean matchResult = matchesExactly(aSig,world,allowBridgeMethods,subjectMatch); if (matchResult.alwaysTrue()) { return true; } else if (matchResult.alwaysFalse()) { return false; } // if we got a "MAYBE" it's worth looking at the other signatures + subjectMatch = false; } return false; } @@ -299,14 +301,14 @@ public class SignaturePattern extends PatternNode { // or chasing up the hierarchy) // return YES if it does, NO if it doesn't and no ancester member could match either, // and MAYBE if it doesn't but an ancester member could. - private FuzzyBoolean matchesExactly(JoinPointSignature aMember, World inAWorld, boolean allowBridgeMethods) { + private FuzzyBoolean matchesExactly(JoinPointSignature aMember, World inAWorld, boolean allowBridgeMethods,boolean subjectMatch) { // Java5 introduces bridge methods, we match a call to them but nothing else... if (aMember.isBridgeMethod() && !allowBridgeMethods) { return FuzzyBoolean.MAYBE; } // modifiers match on the *subject* - if (!modifiers.matches(aMember.getModifiers())) { + if (subjectMatch && !modifiers.matches(aMember.getModifiers())) { return FuzzyBoolean.NO; // if (aMember.isPrivate()) return FuzzyBoolean.NO; // else return FuzzyBoolean.MAYBE; @@ -319,14 +321,14 @@ public class SignaturePattern extends PatternNode { } else if (kind == Member.FIELD) { matchesIgnoringAnnotations = matchesExactlyField(aMember,inAWorld); } else if (kind == Member.METHOD) { - matchesIgnoringAnnotations = matchesExactlyMethod(aMember,inAWorld); + matchesIgnoringAnnotations = matchesExactlyMethod(aMember,inAWorld, subjectMatch); } else if (kind == Member.CONSTRUCTOR) { matchesIgnoringAnnotations = matchesExactlyConstructor(aMember, inAWorld); } if (matchesIgnoringAnnotations.alwaysFalse()) return FuzzyBoolean.NO; // annotations match on the *subject* - if (!matchesAnnotations(aMember,inAWorld).alwaysTrue()) { + if (subjectMatch && !matchesAnnotations(aMember,inAWorld).alwaysTrue()) { return FuzzyBoolean.NO; } else { return matchesIgnoringAnnotations; @@ -364,10 +366,10 @@ public class SignaturePattern extends PatternNode { /** * Matches on name, declaring type, return type, parameter types, throws types */ - private FuzzyBoolean matchesExactlyMethod(JoinPointSignature aMethod, World world) { + private FuzzyBoolean matchesExactlyMethod(JoinPointSignature aMethod, World world, boolean subjectMatch) { if (!name.matches(aMethod.getName())) return FuzzyBoolean.NO; // Check the throws pattern - if (!throwsPattern.matches(aMethod.getExceptions(), world)) return FuzzyBoolean.NO; + if (subjectMatch && !throwsPattern.matches(aMethod.getExceptions(), world)) return FuzzyBoolean.NO; if (!declaringType.matchesStatically(aMethod.getDeclaringType().resolve(world))) return FuzzyBoolean.MAYBE; if (!returnType.matchesStatically(aMethod.getReturnType().resolve(world))) { -- 2.39.5