From f278ada0825351d99be1f32ab63be2f0b0fda3cf Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 27 Aug 2008 22:59:46 +0000 Subject: [PATCH] 211607: test and fix --- .../org/aspectj/weaver/bcel/BcelShadow.java | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java index 5052952a7..8bef3fa0a 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java @@ -2388,7 +2388,7 @@ public class BcelShadow extends Shadow { parameterTypes, parameterIndex, adviceParameterTypes.length); - +// parameterTypes is [Bug, C, org.aspectj.lang.JoinPoint, X, org.aspectj.lang.ProceedingJoinPoint, java.lang.Object, java.lang.Object] LazyMethodGen localAdviceMethod = new LazyMethodGen( Modifier.PRIVATE | Modifier.FINAL | Modifier.STATIC, @@ -2680,7 +2680,7 @@ public class BcelShadow extends Shadow { if (isProceedWithArgs) { // STORE the Object[] into a local variable - Type objectArrayType = Type.getType("[Ljava/lang/Object;"); + Type objectArrayType = Type.OBJECT_ARRAY; int localProceedArgArray = localAdviceMethod.allocateLocal(objectArrayType); ret.append(InstructionFactory.createStore(objectArrayType, localProceedArgArray)); @@ -2705,26 +2705,30 @@ public class BcelShadow extends Shadow { // two numbers can differ because a pointcut may bind both this/target and yet at the // join point this and target are the same (eg. call) - int indexIntoObjectArrayForArguments=0; int indexIntoCallbackMethodForArguments = 0; - if (hasThis()) { - if (relatedPointcutBindsThis) { - if (!(relatedPointcutBindsTarget && targetIsSameAsThis)) { - // they have supplied new this as first entry in object array - ret.append(InstructionFactory.createLoad(objectArrayType, localProceedArgArray)); - ret.append(Utility.createConstant(fact, 0)); - ret.append(InstructionFactory.createArrayLoad(Type.OBJECT)); - ret.append(Utility.createConversion(fact,Type.OBJECT,callbackMethod.getArgumentTypes()[0])); - indexIntoCallbackMethodForArguments++; - } - indexIntoObjectArrayForArguments=1; - } else { - // use local variable 0 (which is 'this' for a non-static method) - ret.append(InstructionFactory.createALOAD(0)); - indexIntoCallbackMethodForArguments++; - } + + + if (hasThis() ) { + if (!(relatedPointcutBindsTarget && targetIsSameAsThis)) { + if (relatedPointcutBindsThis) { + // if (!(relatedPointcutBindsTarget && targetIsSameAsThis)) { + // they have supplied new this as first entry in object array + ret.append(InstructionFactory.createLoad(objectArrayType, localProceedArgArray)); + ret.append(Utility.createConstant(fact, 0)); + ret.append(InstructionFactory.createArrayLoad(Type.OBJECT)); + ret.append(Utility.createConversion(fact,Type.OBJECT,callbackMethod.getArgumentTypes()[0])); + indexIntoCallbackMethodForArguments++; + // } + } else { + // use local variable 0 (which is 'this' for a non-static method) + ret.append(InstructionFactory.createALOAD(0)); + indexIntoCallbackMethodForArguments++; + } + } } + + if (hasTarget()) { if (relatedPointcutBindsTarget) { if (getKind().isTargetSameAsThis()) { @@ -2732,7 +2736,6 @@ public class BcelShadow extends Shadow { ret.append(Utility.createConstant(fact, relatedPointcutBindsThis?1:0)); ret.append(InstructionFactory.createArrayLoad(Type.OBJECT)); ret.append(Utility.createConversion(fact,Type.OBJECT,callbackMethod.getArgumentTypes()[0])); - indexIntoObjectArrayForArguments++; indexIntoCallbackMethodForArguments++; } else { int position =(hasThis()&& relatedPointcutBindsThis?1:0); @@ -2740,7 +2743,6 @@ public class BcelShadow extends Shadow { ret.append(Utility.createConstant(fact, position)); ret.append(InstructionFactory.createArrayLoad(Type.OBJECT)); ret.append(Utility.createConversion(fact,Type.OBJECT,callbackMethod.getArgumentTypes()[position])); - indexIntoObjectArrayForArguments=position+1; indexIntoCallbackMethodForArguments++; } } else { @@ -2753,6 +2755,9 @@ public class BcelShadow extends Shadow { } } + // Where to start in the object array in order to pick up arguments + int indexIntoObjectArrayForArguments = (relatedPointcutBindsThis?1:0)+(relatedPointcutBindsTarget?1:0); + for (int i = indexIntoCallbackMethodForArguments, len=callbackMethod.getArgumentTypes().length; i < len; i++) { Type stateType = callbackMethod.getArgumentTypes()[i]; -- 2.39.5