From fb0ebe4eddae6bf7bcc272c919d25d19d72c7c0d Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 28 Jan 2009 01:07:27 +0000 Subject: [PATCH] refactoring to make around advice lvt fixes easier to apply - and make the code a bit clearer --- .../org/aspectj/weaver/bcel/BcelShadow.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java index fc170d6d7..ae2109df7 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java @@ -2190,20 +2190,21 @@ public class BcelShadow extends Shadow { // parameterTypes is [Bug, C, org.aspectj.lang.JoinPoint, X, org.aspectj.lang.ProceedingJoinPoint, java.lang.Object, // java.lang.Object] - // now extract the advice into its own method - String localAdviceMethodName = NameMangler.aroundAdviceMethodName(getSignature(), new Integer(getEnclosingClass() - .getNewGeneratedNameTag()).toString()); + // Extract the advice into a new method. This will go in the same type as the shadow + // name will be something like foo_aroundBody1$advice + String localAdviceMethodName = NameMangler.aroundAdviceMethodName(getSignature(), shadowClass.getNewGeneratedNameTag()); LazyMethodGen localAdviceMethod = new LazyMethodGen(Modifier.PRIVATE | Modifier.FINAL | Modifier.STATIC, BcelWorld - .makeBcelType(mungerSig.getReturnType()), localAdviceMethodName, parameterTypes, new String[0], getEnclosingClass()); - - String donorFileName = adviceMethod.getEnclosingClass().getInternalFileName(); - String recipientFileName = getEnclosingClass().getInternalFileName(); - // System.err.println("donor " + donorFileName); - // System.err.println("recip " + recipientFileName); - if (!donorFileName.equals(recipientFileName)) { - localAdviceMethod.fromFilename = donorFileName; - getEnclosingClass().addInlinedSourceFileInfo(donorFileName, adviceMethod.highestLineNumber); - } + .makeBcelType(mungerSig.getReturnType()), localAdviceMethodName, parameterTypes, NoDeclaredExceptions, shadowClass); + + // Doesnt work properly, so leave it out: (jsr45 support) + // String donorFileName = adviceMethod.getEnclosingClass().getInternalFileName(); + // String recipientFileName = getEnclosingClass().getInternalFileName(); + // // System.err.println("donor " + donorFileName); + // // System.err.println("recip " + recipientFileName); + // if (!donorFileName.equals(recipientFileName)) { + // localAdviceMethod.fromFilename = donorFileName; + // getEnclosingClass().addInlinedSourceFileInfo(donorFileName, adviceMethod.highestLineNumber); + // } shadowClass.addMethodGen(localAdviceMethod); @@ -2223,8 +2224,6 @@ public class BcelShadow extends Shadow { localAdviceMethod.setMaxLocals(nVars); - // System.err.println(localAdviceMethod); - // the shadow is now empty. First, create a correct call // to the around advice. This includes both the call (which may involve // value conversion of the advice arguments) and the return @@ -2971,9 +2970,10 @@ public class BcelShadow extends Shadow { LazyMethodGen extractShadowInstructionsIntoNewMethod(String extractedMethodName, int extractedMethodVisibilityModifier, ISourceLocation adviceSourceLocation) { // LazyMethodGen.assertGoodBody(range.getBody(), extractedMethodName); - if (!getKind().allowsExtraction()) + if (!getKind().allowsExtraction()) { throw new BCException("Attempt to extract method from a shadow kind (" + getKind() + ") that does not support this operation"); + } LazyMethodGen newMethod = createShadowMethodGen(extractedMethodName, extractedMethodVisibilityModifier); IntMap remapper = makeRemap(); range.extractInstructionsInto(newMethod, remapper, (getKind() != PreInitialization) && isFallsThrough()); -- 2.39.5