aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2006-10-03 10:32:55 +0000
committeraclement <aclement>2006-10-03 10:32:55 +0000
commita0c198f33de6031842024b3ef36314420e535632 (patch)
tree21951487085e1a6fec62e37f7fa3b9080df4c0af
parente8959972193b4f74b173daca878f4af77089ccb8 (diff)
downloadaspectj-a0c198f33de6031842024b3ef36314420e535632.tar.gz
aspectj-a0c198f33de6031842024b3ef36314420e535632.zip
fixes for 145442: better line numbers for woven code
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelShadow.java23
1 files changed, 17 insertions, 6 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
index f1694cbb0..50d8bb045 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
@@ -43,6 +43,7 @@ import org.aspectj.apache.bcel.generic.InstructionHandle;
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;
@@ -412,10 +413,13 @@ public class BcelShadow extends Shadow {
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) ||
@@ -424,20 +428,23 @@ public class BcelShadow extends Shadow {
(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
@@ -2930,6 +2937,7 @@ public class BcelShadow extends Shadow {
enclosingMethod.setCanInline(false);
+ int linenumber = getSourceLine();
// MOVE OUT ALL THE INSTRUCTIONS IN MY SHADOW INTO ANOTHER METHOD!
LazyMethodGen callbackMethod =
extractMethod(
@@ -3050,6 +3058,9 @@ public class BcelShadow extends Shadow {
// 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);