diff options
author | aclement <aclement> | 2009-10-02 03:53:47 +0000 |
---|---|---|
committer | aclement <aclement> | 2009-10-02 03:53:47 +0000 |
commit | 92c8cc8aafed59909f013b3f33297c999cd0b4a9 (patch) | |
tree | b2e5eb8e48cb1ac086830bb693e832f62b70bccb /weaver | |
parent | 4c83b12c753cffe0dc0165e5e3a0210e8f9f3f26 (diff) | |
download | aspectj-92c8cc8aafed59909f013b3f33297c999cd0b4a9.tar.gz aspectj-92c8cc8aafed59909f013b3f33297c999cd0b4a9.zip |
refactoring
Diffstat (limited to 'weaver')
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java | 20 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/BcelShadow.java | 63 |
2 files changed, 51 insertions, 32 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java index 22cedb3e8..a5ec39617 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java @@ -223,19 +223,27 @@ class BcelAdvice extends Advice { return boType.getLazyClassGen().isWoven(); } + private boolean aspectIsBroken() { + if (concreteAspect instanceof ReferenceType) { + ReferenceTypeDelegate rtDelegate = ((ReferenceType) concreteAspect).getDelegate(); + if (!(rtDelegate instanceof BcelObjectType)) { + return true; + } + } + return false; + } + @Override public boolean implementOn(Shadow s) { hasMatchedAtLeastOnce = true; - BcelShadow shadow = (BcelShadow) s; // pr263323 - if the aspect is broken then the delegate will not be usable for weaving - if (concreteAspect instanceof ReferenceType) { - ReferenceTypeDelegate rtDelegate = ((ReferenceType) concreteAspect).getDelegate(); - if (!(rtDelegate instanceof BcelObjectType)) { - return false; - } + if (aspectIsBroken()) { + return false; } + BcelShadow shadow = (BcelShadow) s; + // remove any unnecessary exceptions if the compiler option is set to // error or warning and if this piece of advice throws exceptions // (bug 129282). This may be expanded to include other compiler warnings diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java index 97c49ee92..a878047ef 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java @@ -2136,32 +2136,8 @@ public class BcelShadow extends Shadow { } // specific test for @AJ proceedInInners - if (munger.getConcreteAspect().isAnnotationStyleAspect()) { - // if we can't find one proceed() we suspect that the call - // is happening in an inner class so we don't inline it. - // Note: for code style, this is done at Aspect compilation time. - boolean canSeeProceedPassedToOther = false; - InstructionHandle curr = adviceMethod.getBody().getStart(); - InstructionHandle end = adviceMethod.getBody().getEnd(); - ConstantPool cpg = adviceMethod.getEnclosingClass().getConstantPool(); - while (curr != end) { - InstructionHandle next = curr.getNext(); - Instruction inst = curr.getInstruction(); - if ((inst instanceof InvokeInstruction) - && ((InvokeInstruction) inst).getSignature(cpg).indexOf("Lorg/aspectj/lang/ProceedingJoinPoint;") > 0) { - // we may want to refine to exclude stuff returning jp ? - // does code style skip inline if i write dump(thisJoinPoint) ? - canSeeProceedPassedToOther = true;// we see one pjp passed around - dangerous - break; - } - curr = next; - } - if (canSeeProceedPassedToOther) { - // remember this decision to avoid re-analysis - adviceMethod.setCanInline(false); - weaveAroundClosure(munger, hasDynamicTest); - return; - } + if (isAnnotationStylePassingProceedingJoinPointOutOfAdvice(munger, hasDynamicTest, adviceMethod)) { + return; } // We can't inline around methods if they have around advice on them, this @@ -2406,6 +2382,41 @@ public class BcelShadow extends Shadow { } } + /** + * Check if the advice method passes a pjp parameter out via an invoke instruction - if so we can't risk inlining. + */ + private boolean isAnnotationStylePassingProceedingJoinPointOutOfAdvice(BcelAdvice munger, boolean hasDynamicTest, + LazyMethodGen adviceMethod) { + if (munger.getConcreteAspect().isAnnotationStyleAspect()) { + // if we can't find one proceed() we suspect that the call + // is happening in an inner class so we don't inline it. + // Note: for code style, this is done at Aspect compilation time. + boolean canSeeProceedPassedToOther = false; + InstructionHandle curr = adviceMethod.getBody().getStart(); + InstructionHandle end = adviceMethod.getBody().getEnd(); + ConstantPool cpg = adviceMethod.getEnclosingClass().getConstantPool(); + while (curr != end) { + InstructionHandle next = curr.getNext(); + Instruction inst = curr.getInstruction(); + if ((inst instanceof InvokeInstruction) + && ((InvokeInstruction) inst).getSignature(cpg).indexOf("Lorg/aspectj/lang/ProceedingJoinPoint;") > 0) { + // we may want to refine to exclude stuff returning jp ? + // does code style skip inline if i write dump(thisJoinPoint) ? + canSeeProceedPassedToOther = true;// we see one pjp passed around - dangerous + break; + } + curr = next; + } + if (canSeeProceedPassedToOther) { + // remember this decision to avoid re-analysis + adviceMethod.setCanInline(false); + weaveAroundClosure(munger, hasDynamicTest); + return true; + } + } + return false; + } + private InstructionList getRedoneProceedCall(InstructionFactory fact, LazyMethodGen callbackMethod, BcelAdvice munger, LazyMethodGen localAdviceMethod, List<BcelVar> argVarList) { InstructionList ret = new InstructionList(); |