diff options
author | jhugunin <jhugunin> | 2002-12-17 23:17:35 +0000 |
---|---|---|
committer | jhugunin <jhugunin> | 2002-12-17 23:17:35 +0000 |
commit | a6d1918ba0e713546a214901de6eda9376604877 (patch) | |
tree | 18ddd98ce46820a291f64b353bcc7ec967211855 /weaver | |
parent | 4f58fd779099e3a59c6c1e177f94b86b6c7b5f47 (diff) | |
download | aspectj-a6d1918ba0e713546a214901de6eda9376604877.tar.gz aspectj-a6d1918ba0e713546a214901de6eda9376604877.zip |
adding accessor methods for calls to protected methods from inter-type
declarations just like we have from calls to super methods
Diffstat (limited to 'weaver')
-rw-r--r-- | weaver/src/org/aspectj/weaver/NameMangler.java | 13 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java | 29 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java | 2 |
3 files changed, 26 insertions, 18 deletions
diff --git a/weaver/src/org/aspectj/weaver/NameMangler.java b/weaver/src/org/aspectj/weaver/NameMangler.java index 69a3271fa..3d9bc8c11 100644 --- a/weaver/src/org/aspectj/weaver/NameMangler.java +++ b/weaver/src/org/aspectj/weaver/NameMangler.java @@ -231,14 +231,23 @@ public class NameMangler { // ---- /** - * This static method goes on the declaring aspect of the inter-type method. + * This static method goes on the target class of the inter-type method. */ - public static String superDispatcher(TypeX classType, String name) + public static String superDispatchMethod(TypeX classType, String name) { return makeName("superDispatch", classType.getNameAsIdentifier(), name); } + /** + * This static method goes on the target class of the inter-type method. + */ + public static String protectedDispatchMethod(TypeX classType, String name) + { + return makeName("protectedDispatch", + classType.getNameAsIdentifier(), name); + } + // ---- private static TypeX getOutermostType(TypeX type) { diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java index a14f0e0b3..89e085fba 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java @@ -300,8 +300,12 @@ public class BcelTypeMunger extends ConcreteTypeMunger { for (Iterator iter = neededSuperCalls.iterator(); iter.hasNext(); ) { ResolvedMember superMethod = (ResolvedMember) iter.next(); if (weaver.addDispatchTarget(superMethod)) { - String dispatchName = genSuperDispatchName(onType, superMethod); - LazyMethodGen dispatcher = makeDispatcher(gen, dispatchName, superMethod, weaver.getWorld()); + //System.err.println("super type: " + superMethod.getDeclaringType() + ", " + gen.getType()); + boolean isSuper = !superMethod.getDeclaringType().equals(gen.getType()); + String dispatchName; + if (isSuper) dispatchName = NameMangler.superDispatchMethod(onType, superMethod.getName()); + else dispatchName = NameMangler.protectedDispatchMethod(onType, superMethod.getName()); + LazyMethodGen dispatcher = makeDispatcher(gen, dispatchName, superMethod, weaver.getWorld(), isSuper); weaver.addLazyMethodGen(dispatcher); } @@ -433,7 +437,8 @@ public class BcelTypeMunger extends ConcreteTypeMunger { LazyClassGen onGen, String dispatchName, ResolvedMember superMethod, - BcelWorld world) + BcelWorld world, + boolean isSuper) { Type[] paramTypes = BcelWorld.makeBcelTypes(superMethod.getParameterTypes()); Type returnType = BcelWorld.makeBcelType(superMethod.getReturnType()); @@ -459,21 +464,15 @@ public class BcelTypeMunger extends ConcreteTypeMunger { body.append(fact.createLoad(paramType, pos)); pos+=paramType.getSize(); } - body.append(Utility.createSuperInvoke(fact, world, superMethod)); + if (isSuper) { + body.append(Utility.createSuperInvoke(fact, world, superMethod)); + } else { + body.append(Utility.createInvoke(fact, world, superMethod)); + } body.append(fact.createReturn(returnType)); return mg; - } - - - private static String genSuperDispatchName( - ResolvedTypeX onType, - ResolvedMember superMethod) - { - return "ajc$" + ResolvedTypeMunger.SUPER_DISPATCH_NAME + "$" + onType.getNameAsIdentifier() + "$" + superMethod.getName(); - } - - + } private boolean mungeNewField(BcelClassWeaver weaver, NewFieldTypeMunger munger) { ResolvedMember initMethod = munger.getInitMethod(aspectType); diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java index 63eb043d5..c0e475cbd 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java @@ -283,7 +283,7 @@ public class BcelWeaver implements IWeaver { LazyClassGen clazz = null; - if (shadowMungers.size() > 0 || typeMungers.size() > 0) { + if (shadowMungers.size() > 0 || typeMungers.size() > 0 || classType.isAspect()) { clazz = classType.getLazyClassGen(); try { boolean isChanged = BcelClassWeaver.weave(world, clazz, shadowMungers, typeMungers); |