From 8459fc93a9f455b2669ed2a758b10bdc6cd3903a Mon Sep 17 00:00:00 2001 From: acolyer Date: Tue, 6 Sep 2005 11:02:20 +0000 Subject: fix for pr108818, if the declaring type of the member refering to this pointcut has a private matching pointcut, then use that rather than any with the same name in a sub-aspect. --- .../aspectj/weaver/patterns/ReferencePointcut.java | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java b/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java index 15e6f8cfd..39afad012 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java @@ -251,7 +251,10 @@ public class ReferencePointcut extends Pointcut { //??? This is not thread safe, but this class is not designed for multi-threading private boolean concretizing = false; - public Pointcut concretize1(ResolvedType searchStart, IntMap bindings) { + // declaring type is the type that declared the member referencing this pointcut. + // If it declares a matching private pointcut, then that pointcut should be used + // and not one in a subtype that happens to have the same name. + public Pointcut concretize1(ResolvedType searchStart, ResolvedType declaringType, IntMap bindings) { if (concretizing) { //Thread.currentThread().dumpStack(); searchStart.getWorld().getMessageHandler().handleMessage( @@ -270,13 +273,19 @@ public class ReferencePointcut extends Pointcut { return Pointcut.makeMatchesNothing(Pointcut.CONCRETE); } } - pointcutDec = searchStart.findPointcut(name); - if (pointcutDec == null) { - searchStart.getWorld().getMessageHandler().handleMessage( - MessageUtil.error(WeaverMessages.format(WeaverMessages.CANT_FIND_POINTCUT,name,searchStart.getName()), - getSourceLocation()) - ); - return Pointcut.makeMatchesNothing(Pointcut.CONCRETE); + + if (declaringType == null) declaringType = searchStart; + pointcutDec = declaringType.findPointcut(name); + boolean foundMatchingPointcut = (pointcutDec != null && pointcutDec.isPrivate()); + if (!foundMatchingPointcut) { + pointcutDec = searchStart.findPointcut(name); + if (pointcutDec == null) { + searchStart.getWorld().getMessageHandler().handleMessage( + MessageUtil.error(WeaverMessages.format(WeaverMessages.CANT_FIND_POINTCUT,name,searchStart.getName()), + getSourceLocation()) + ); + return Pointcut.makeMatchesNothing(Pointcut.CONCRETE); + } } if (pointcutDec.isAbstract()) { @@ -327,7 +336,7 @@ public class ReferencePointcut extends Pointcut { try { Pointcut ret = pointcutDec.getPointcut(); if (typeVariableMap != null) ret = ret.parameterizeWith(typeVariableMap); - return ret.concretize(searchStart, newBindings); + return ret.concretize(searchStart, declaringType, newBindings); } finally { newBindings.popEnclosingDefinitition(); } -- cgit v1.2.3