import org.aspectj.apache.bcel.generic.InstructionList;
import org.aspectj.apache.bcel.generic.InstructionTargeter;
import org.aspectj.apache.bcel.generic.InvokeInstruction;
+import org.aspectj.apache.bcel.generic.LineNumberTag;
import org.aspectj.apache.bcel.generic.LoadInstruction;
import org.aspectj.apache.bcel.generic.LocalVariableTag;
import org.aspectj.apache.bcel.generic.MULTIANEWARRAY;
this.range = range;
}
+ private int sourceline = -1;
+
public int getSourceLine() {
// if the kind of join point for which we are a shadow represents
// a method or constructor execution, then the best source line is
// the one from the enclosingMethod declarationLineNumber if available.
+ if (sourceline!=-1) return sourceline;
Kind kind = getKind();
if ( (kind == MethodExecution) ||
(kind == ConstructorExecution) ||
(kind == PreInitialization) ||
(kind == Initialization)) {
if (getEnclosingMethod().hasDeclaredLineNumberInfo()) {
- return getEnclosingMethod().getDeclarationLineNumber();
+ sourceline= getEnclosingMethod().getDeclarationLineNumber();
+ return sourceline;
}
}
if (range == null) {
if (getEnclosingMethod().hasBody()) {
- return Utility.getSourceLine(getEnclosingMethod().getBody().getStart());
+ sourceline= Utility.getSourceLine(getEnclosingMethod().getBody().getStart());
+ return sourceline;
} else {
- return 0;
+ sourceline= 0;
+ return sourceline;
}
}
- int ret = Utility.getSourceLine(range.getStart());
- if (ret < 0) return 0;
- return ret;
+ sourceline = Utility.getSourceLine(range.getStart());
+ if (sourceline < 0) sourceline = 0;
+ return sourceline;
}
// overrides
enclosingMethod.setCanInline(false);
+ int linenumber = getSourceLine();
// MOVE OUT ALL THE INSTRUCTIONS IN MY SHADOW INTO ANOTHER METHOD!
LazyMethodGen callbackMethod =
extractMethod(
// invoke the advice
advice.append(munger.getNonTestAdviceInstructions(this));
advice.append(returnConversionCode);
+ if (getKind()==Shadow.MethodExecution) {
+ advice.getStart().addTargeter(new LineNumberTag(linenumber));
+ }
if (!hasDynamicTest) {
range.append(advice);