aclement 14 лет назад
Родитель
Сommit
92c8cc8aaf

+ 14
- 6
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

+ 37
- 26
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();

Загрузка…
Отмена
Сохранить