diff options
author | acolyer <acolyer> | 2004-08-19 12:29:04 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2004-08-19 12:29:04 +0000 |
commit | 65c67a4e848311efb7402f5d06bd1a833720b94b (patch) | |
tree | fdb6a106aa7059922e42adb079516a04c4093514 /weaver | |
parent | 2834a7c26b42b8d98af57ef9733ae94fa4aa4a5b (diff) | |
download | aspectj-65c67a4e848311efb7402f5d06bd1a833720b94b.tar.gz aspectj-65c67a4e848311efb7402f5d06bd1a833720b94b.zip |
fix for Bugzilla Bug 37020
wrong line for method execution join point
Diffstat (limited to 'weaver')
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 Binary files differindex baf5a2a25..b61752c66 100644 --- a/weaver/testdata/dummyAspect.jar +++ b/weaver/testdata/dummyAspect.jar diff --git a/weaver/testdata/ltw-acaspects.jar b/weaver/testdata/ltw-acaspects.jar Binary files differindex 3fe72d9d7..0ef9dc1ab 100644 --- a/weaver/testdata/ltw-acaspects.jar +++ b/weaver/testdata/ltw-acaspects.jar diff --git a/weaver/testdata/ltw-aspects.jar b/weaver/testdata/ltw-aspects.jar Binary files differindex 2f232c71f..ae188557a 100644 --- a/weaver/testdata/ltw-aspects.jar +++ b/weaver/testdata/ltw-aspects.jar diff --git a/weaver/testdata/ltw-classes.jar b/weaver/testdata/ltw-classes.jar Binary files differindex 64aa2aee4..ec7b131b8 100644 --- a/weaver/testdata/ltw-classes.jar +++ b/weaver/testdata/ltw-classes.jar diff --git a/weaver/testdata/ltw-deaspects.jar b/weaver/testdata/ltw-deaspects.jar Binary files differindex 982c609ad..261df4f6b 100644 --- a/weaver/testdata/ltw-deaspects.jar +++ b/weaver/testdata/ltw-deaspects.jar diff --git a/weaver/testdata/ltw-dwaspects.jar b/weaver/testdata/ltw-dwaspects.jar Binary files differindex d3cbc6728..e32be29da 100644 --- a/weaver/testdata/ltw-dwaspects.jar +++ b/weaver/testdata/ltw-dwaspects.jar diff --git a/weaver/testdata/ltw-itdaspects.jar b/weaver/testdata/ltw-itdaspects.jar Binary files differindex 868c3b917..6081aac7b 100644 --- a/weaver/testdata/ltw-itdaspects.jar +++ b/weaver/testdata/ltw-itdaspects.jar diff --git a/weaver/testdata/ltw-peraspects.jar b/weaver/testdata/ltw-peraspects.jar Binary files differindex 0a903503e..3985ca928 100644 --- a/weaver/testdata/ltw-peraspects.jar +++ b/weaver/testdata/ltw-peraspects.jar diff --git a/weaver/testdata/ltw-woven.jar b/weaver/testdata/ltw-woven.jar Binary files differindex c83beb557..1988c2de9 100644 --- a/weaver/testdata/ltw-woven.jar +++ b/weaver/testdata/ltw-woven.jar diff --git a/weaver/testdata/megatrace.jar b/weaver/testdata/megatrace.jar Binary files differindex 7b82aa215..c644fa735 100644 --- a/weaver/testdata/megatrace.jar +++ b/weaver/testdata/megatrace.jar diff --git a/weaver/testdata/megatrace0easy.jar b/weaver/testdata/megatrace0easy.jar Binary files differindex 24ec93afb..828380339 100644 --- a/weaver/testdata/megatrace0easy.jar +++ b/weaver/testdata/megatrace0easy.jar diff --git a/weaver/testdata/megatrace0hard.jar b/weaver/testdata/megatrace0hard.jar Binary files differindex 3fb566030..0a9e8fae8 100644 --- a/weaver/testdata/megatrace0hard.jar +++ b/weaver/testdata/megatrace0hard.jar diff --git a/weaver/testdata/megatraceNoweave.jar b/weaver/testdata/megatraceNoweave.jar Binary files differindex 577944439..ca94b541a 100644 --- a/weaver/testdata/megatraceNoweave.jar +++ b/weaver/testdata/megatraceNoweave.jar diff --git a/weaver/testdata/tracing.jar b/weaver/testdata/tracing.jar Binary files differindex 3a6749657..264fada03 100644 --- a/weaver/testdata/tracing.jar +++ b/weaver/testdata/tracing.jar |