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
}
// 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
}
}
+ /**
+ * 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();