aboutsummaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authoracolyer <acolyer>2004-08-19 12:29:04 +0000
committeracolyer <acolyer>2004-08-19 12:29:04 +0000
commit65c67a4e848311efb7402f5d06bd1a833720b94b (patch)
treefdb6a106aa7059922e42adb079516a04c4093514 /weaver
parent2834a7c26b42b8d98af57ef9733ae94fa4aa4a5b (diff)
downloadaspectj-65c67a4e848311efb7402f5d06bd1a833720b94b.tar.gz
aspectj-65c67a4e848311efb7402f5d06bd1a833720b94b.zip
fix for Bugzilla Bug 37020
wrong line for method execution join point
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/AjAttribute.java28
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelMethod.java17
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelShadow.java15
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java12
-rw-r--r--weaver/testdata/dummyAspect.jarbin811 -> 841 bytes
-rw-r--r--weaver/testdata/ltw-acaspects.jarbin2406 -> 2471 bytes
-rw-r--r--weaver/testdata/ltw-aspects.jarbin1468 -> 1485 bytes
-rw-r--r--weaver/testdata/ltw-classes.jarbin1410 -> 1486 bytes
-rw-r--r--weaver/testdata/ltw-deaspects.jarbin1096 -> 1107 bytes
-rw-r--r--weaver/testdata/ltw-dwaspects.jarbin1100 -> 1112 bytes
-rw-r--r--weaver/testdata/ltw-itdaspects.jarbin4881 -> 4944 bytes
-rw-r--r--weaver/testdata/ltw-peraspects.jarbin1872 -> 1888 bytes
-rw-r--r--weaver/testdata/ltw-woven.jarbin2647 -> 2690 bytes
-rw-r--r--weaver/testdata/megatrace.jarbin5277 -> 5319 bytes
-rw-r--r--weaver/testdata/megatrace0easy.jarbin3246 -> 3279 bytes
-rw-r--r--weaver/testdata/megatrace0hard.jarbin3141 -> 3184 bytes
-rw-r--r--weaver/testdata/megatraceNoweave.jarbin3033 -> 3080 bytes
-rw-r--r--weaver/testdata/tracing.jarbin2606 -> 2663 bytes
18 files changed, 71 insertions, 1 deletions
diff --git a/weaver/src/org/aspectj/weaver/AjAttribute.java b/weaver/src/org/aspectj/weaver/AjAttribute.java
index 417fa7ce5..b194e19af 100644
--- a/weaver/src/org/aspectj/weaver/AjAttribute.java
+++ b/weaver/src/org/aspectj/weaver/AjAttribute.java
@@ -87,6 +87,8 @@ public abstract class AjAttribute {
DataInputStream s = new DataInputStream(new ByteArrayInputStream(bytes));
if (name.equals(Aspect.AttributeName)) {
return new Aspect(PerClause.readPerClause(s, context));
+ } else if (name.equals(MethodDeclarationLineNumberAttribute.AttributeName)) {
+ return MethodDeclarationLineNumberAttribute.read(s);
} else if (name.equals(WeaverState.AttributeName)) {
return new WeaverState(WeaverStateInfo.read(s, context));
} else if (name.equals(AdviceAttribute.AttributeName)) {
@@ -206,6 +208,32 @@ public abstract class AjAttribute {
}
}
+ public static class MethodDeclarationLineNumberAttribute extends AjAttribute {
+
+ public static final String AttributeName = "org.aspectj.weaver.MethodDeclarationLineNumber";
+
+ public String getNameString() {
+ return AttributeName;
+ }
+
+ private int lineNumber;
+
+ public MethodDeclarationLineNumberAttribute(int line) {
+ this.lineNumber = line;
+ }
+
+ public int getLineNumber() { return lineNumber; }
+
+ public void write(DataOutputStream s) throws IOException {
+ s.writeInt(lineNumber);
+ }
+
+ public static MethodDeclarationLineNumberAttribute read(DataInputStream s) throws IOException {
+ return new MethodDeclarationLineNumberAttribute(s.readInt());
+ }
+
+ }
+
public static class PointcutDeclarationAttribute extends AjAttribute {
public static final String AttributeName = "org.aspectj.weaver.PointcutDeclaration";
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java b/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java
index b55184285..202982d76 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java
@@ -34,6 +34,7 @@ final class BcelMethod extends ResolvedMember {
private boolean isAjSynthetic;
private ShadowMunger associatedShadowMunger;
private AjAttribute.EffectiveSignatureAttribute effectiveSignature;
+ private AjAttribute.MethodDeclarationLineNumberAttribute declarationLineNumber;
BcelMethod(BcelObjectType declaringType, Method method) {
super(
@@ -84,7 +85,9 @@ final class BcelMethod extends ResolvedMember {
//System.out.println("unpack: " + this + ", " + as);
for (Iterator iter = as.iterator(); iter.hasNext();) {
AjAttribute a = (AjAttribute) iter.next();
- if (a instanceof AjAttribute.AdviceAttribute) {
+ if (a instanceof AjAttribute.MethodDeclarationLineNumberAttribute) {
+ declarationLineNumber = (AjAttribute.MethodDeclarationLineNumberAttribute)a;
+ } else if (a instanceof AjAttribute.AdviceAttribute) {
associatedShadowMunger = ((AjAttribute.AdviceAttribute)a).reify(this, world);
return;
} else if (a instanceof AjAttribute.AjSynthetic) {
@@ -113,6 +116,18 @@ final class BcelMethod extends ResolvedMember {
return effectiveSignature;
}
+ public boolean hasDeclarationLineNumberInfo() {
+ return declarationLineNumber != null;
+ }
+
+ public int getDeclarationLineNumber() {
+ if (declarationLineNumber != null) {
+ return declarationLineNumber.getLineNumber();
+ } else {
+ return -1;
+ }
+ }
+
public Kind getKind() {
if (associatedShadowMunger != null) {
return ADVICE;
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
index 9e6fd0c29..d521ed52d 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
@@ -303,6 +303,21 @@ public class BcelShadow extends Shadow {
}
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.
+ Kind kind = getKind();
+ if ( (kind == MethodExecution) ||
+ (kind == ConstructorExecution) ||
+ (kind == AdviceExecution) ||
+ (kind == StaticInitialization) ||
+ (kind == PreInitialization) ||
+ (kind == Initialization)) {
+ if (getEnclosingMethod().hasDeclaredLineNumberInfo()) {
+ return getEnclosingMethod().getDeclarationLineNumber();
+ }
+ }
+
if (range == null) {
if (getEnclosingMethod().hasBody()) {
return Utility.getSourceLine(getEnclosingMethod().getBody().getStart());
diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
index f90fe103b..47076f351 100644
--- a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
+++ b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
@@ -161,6 +161,18 @@ public final class LazyMethodGen {
this.name = m.getName();
}
+ public boolean hasDeclaredLineNumberInfo() {
+ return (memberView != null && memberView.hasDeclarationLineNumberInfo());
+ }
+
+ public int getDeclarationLineNumber() {
+ if (hasDeclaredLineNumberInfo()) {
+ return memberView.getDeclarationLineNumber();
+ } else {
+ return -1;
+ }
+ }
+
private void initialize() {
if (returnType != null) return;
diff --git a/weaver/testdata/dummyAspect.jar b/weaver/testdata/dummyAspect.jar
index baf5a2a25..b61752c66 100644
--- a/weaver/testdata/dummyAspect.jar
+++ b/weaver/testdata/dummyAspect.jar
Binary files differ
diff --git a/weaver/testdata/ltw-acaspects.jar b/weaver/testdata/ltw-acaspects.jar
index 3fe72d9d7..0ef9dc1ab 100644
--- a/weaver/testdata/ltw-acaspects.jar
+++ b/weaver/testdata/ltw-acaspects.jar
Binary files differ
diff --git a/weaver/testdata/ltw-aspects.jar b/weaver/testdata/ltw-aspects.jar
index 2f232c71f..ae188557a 100644
--- a/weaver/testdata/ltw-aspects.jar
+++ b/weaver/testdata/ltw-aspects.jar
Binary files differ
diff --git a/weaver/testdata/ltw-classes.jar b/weaver/testdata/ltw-classes.jar
index 64aa2aee4..ec7b131b8 100644
--- a/weaver/testdata/ltw-classes.jar
+++ b/weaver/testdata/ltw-classes.jar
Binary files differ
diff --git a/weaver/testdata/ltw-deaspects.jar b/weaver/testdata/ltw-deaspects.jar
index 982c609ad..261df4f6b 100644
--- a/weaver/testdata/ltw-deaspects.jar
+++ b/weaver/testdata/ltw-deaspects.jar
Binary files differ
diff --git a/weaver/testdata/ltw-dwaspects.jar b/weaver/testdata/ltw-dwaspects.jar
index d3cbc6728..e32be29da 100644
--- a/weaver/testdata/ltw-dwaspects.jar
+++ b/weaver/testdata/ltw-dwaspects.jar
Binary files differ
diff --git a/weaver/testdata/ltw-itdaspects.jar b/weaver/testdata/ltw-itdaspects.jar
index 868c3b917..6081aac7b 100644
--- a/weaver/testdata/ltw-itdaspects.jar
+++ b/weaver/testdata/ltw-itdaspects.jar
Binary files differ
diff --git a/weaver/testdata/ltw-peraspects.jar b/weaver/testdata/ltw-peraspects.jar
index 0a903503e..3985ca928 100644
--- a/weaver/testdata/ltw-peraspects.jar
+++ b/weaver/testdata/ltw-peraspects.jar
Binary files differ
diff --git a/weaver/testdata/ltw-woven.jar b/weaver/testdata/ltw-woven.jar
index c83beb557..1988c2de9 100644
--- a/weaver/testdata/ltw-woven.jar
+++ b/weaver/testdata/ltw-woven.jar
Binary files differ
diff --git a/weaver/testdata/megatrace.jar b/weaver/testdata/megatrace.jar
index 7b82aa215..c644fa735 100644
--- a/weaver/testdata/megatrace.jar
+++ b/weaver/testdata/megatrace.jar
Binary files differ
diff --git a/weaver/testdata/megatrace0easy.jar b/weaver/testdata/megatrace0easy.jar
index 24ec93afb..828380339 100644
--- a/weaver/testdata/megatrace0easy.jar
+++ b/weaver/testdata/megatrace0easy.jar
Binary files differ
diff --git a/weaver/testdata/megatrace0hard.jar b/weaver/testdata/megatrace0hard.jar
index 3fb566030..0a9e8fae8 100644
--- a/weaver/testdata/megatrace0hard.jar
+++ b/weaver/testdata/megatrace0hard.jar
Binary files differ
diff --git a/weaver/testdata/megatraceNoweave.jar b/weaver/testdata/megatraceNoweave.jar
index 577944439..ca94b541a 100644
--- a/weaver/testdata/megatraceNoweave.jar
+++ b/weaver/testdata/megatraceNoweave.jar
Binary files differ
diff --git a/weaver/testdata/tracing.jar b/weaver/testdata/tracing.jar
index 3a6749657..264fada03 100644
--- a/weaver/testdata/tracing.jar
+++ b/weaver/testdata/tracing.jar
Binary files differ