From 769afc68966b6ea101dfebca14c6d67bd426bfa0 Mon Sep 17 00:00:00 2001 From: jhugunin Date: Wed, 5 Mar 2003 19:34:28 +0000 Subject: [PATCH] handling kinds more carefully for shadow sigs so that we can check for matching kinds with SignaturePattern --- .../org/aspectj/weaver/bcel/BcelMethod.java | 11 ++++++++- .../org/aspectj/weaver/bcel/BcelShadow.java | 2 +- .../org/aspectj/weaver/bcel/BcelWorld.java | 24 +++++++++++-------- .../weaver/patterns/SignaturePattern.java | 14 +++++------ 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java b/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java index 696a5df4d..9d38b2fd4 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java @@ -37,7 +37,8 @@ final class BcelMethod extends ResolvedMember { BcelMethod(BcelObjectType declaringType, Method method) { super( - method.getName().equals("") ? CONSTRUCTOR : METHOD, + method.getName().equals("") ? CONSTRUCTOR : + (method.getName().equals("") ? STATIC_INITIALIZATION : METHOD), declaringType, declaringType.isInterface() ? method.getAccessFlags() | Modifier.INTERFACE @@ -113,4 +114,12 @@ final class BcelMethod extends ResolvedMember { public AjAttribute.EffectiveSignatureAttribute getEffectiveSignature() { return effectiveSignature; } + + public Kind getKind() { + if (associatedShadowMunger != null) { + return ADVICE; + } else { + return super.getKind(); + } + } } diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java index cff8c4fa9..c1417b7a6 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java @@ -538,7 +538,7 @@ public class BcelShadow extends Shadow { new BcelShadow( world, AdviceExecution, - world.makeMethodSignature(enclosingMethod), + world.makeMethodSignature(enclosingMethod, Member.ADVICE), enclosingMethod, null); ShadowRange r = new ShadowRange(body); diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java b/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java index 27249e2cf..b683aff61 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java @@ -252,24 +252,28 @@ public class BcelWorld extends World { fi.getName(cpg), "(" + fi.getSignature(cpg) + ")" +fi.getSignature(cpg)); } - + public Member makeMethodSignature(LazyMethodGen mg) { + return makeMethodSignature(mg, null); + } + + + public Member makeMethodSignature(LazyMethodGen mg, Member.Kind kind) { ResolvedMember ret = mg.getMemberView(); if (ret == null) { int mods = mg.getAccessFlags(); if (mg.getEnclosingClass().isInterface()) { mods |= Modifier.INTERFACE; } - - org.aspectj.weaver.Member.Kind kind; - if (mg.getName().equals("")) { - kind = Member.CONSTRUCTOR; - } else if (mg.getName().equals("")) { - kind = Member.STATIC_INITIALIZATION; - } else { - kind = Member.METHOD; + if (kind == null) { + if (mg.getName().equals("")) { + kind = Member.CONSTRUCTOR; + } else if (mg.getName().equals("")) { + kind = Member.STATIC_INITIALIZATION; + } else { + kind = Member.METHOD; + } } - return new ResolvedMember(kind, TypeX.forName(mg.getClassName()), mods, diff --git a/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java b/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java index d07a2bb12..28ffb33dc 100644 --- a/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java @@ -93,16 +93,16 @@ public class SignaturePattern extends PatternNode { world.getLint().unresolvableMember.signal(member.toString(), getSourceLocation()); return false; } - - // AMC test for Kind match surely??? - if (!(sig.getKind() == kind)) return false; - - + + // This check should only matter when used from WithincodePointcut as KindedPointcut + // has already effectively checked this with the shadows kind. + if (kind != member.getKind()) { + return false; + } + if (kind == Member.ADVICE) return true; if (!modifiers.matches(sig.getModifiers())) return false; - - if (kind == Member.STATIC_INITIALIZATION) { //System.err.println("match static init: " + sig.getDeclaringType() + " with " + this); -- 2.39.5