diff options
author | acolyer <acolyer> | 2005-09-01 19:47:37 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-09-01 19:47:37 +0000 |
commit | 619f8bc764e127d4f43ece87ae0e858f7329ec9e (patch) | |
tree | de98a1d3e39ca1b1a4a47228fcb3fa27aee2c095 | |
parent | c6bc7a2b2ee30b7647d3cb17fc323ebf96768fef (diff) | |
download | aspectj-619f8bc764e127d4f43ece87ae0e858f7329ec9e.tar.gz aspectj-619f8bc764e127d4f43ece87ae0e858f7329ec9e.zip |
fix for pr98290, 'matches declare' relationship not correctly created because offset location missing.
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/BcelShadow.java | 19 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java | 9 |
2 files changed, 25 insertions, 3 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java index 9cad79a29..5125ecc39 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java @@ -3040,10 +3040,23 @@ public class BcelShadow extends Shadow { return getEnclosingClass().getType().getSourceLocation(); } else { // For staticinitialization, if we have a nice offset, don't build a new source loc - if (getKind()==Shadow.StaticInitialization && getEnclosingClass().getType().getSourceLocation().getOffset()!=0) + if (getKind()==Shadow.StaticInitialization && getEnclosingClass().getType().getSourceLocation().getOffset()!=0) { return getEnclosingClass().getType().getSourceLocation(); - else - return getEnclosingClass().getType().getSourceContext().makeSourceLocation(sourceLine, 0); + } else { + int offset = 0; + Kind kind = getKind(); + if ( (kind == MethodExecution) || + (kind == ConstructorExecution) || + (kind == AdviceExecution) || + (kind == StaticInitialization) || + (kind == PreInitialization) || + (kind == Initialization)) { + if (getEnclosingMethod().hasDeclaredLineNumberInfo()) { + offset = getEnclosingMethod().getDeclarationOffset(); + } + } + return getEnclosingClass().getType().getSourceContext().makeSourceLocation(sourceLine, offset); + } } } diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java index e3ce8170d..cb31e7a36 100644 --- a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java +++ b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java @@ -210,6 +210,14 @@ public final class LazyMethodGen { } } + public int getDeclarationOffset() { + if (hasDeclaredLineNumberInfo()) { + return memberView.getDeclarationOffset(); + } else { + return 0; + } + } + public void addAnnotation(AnnotationX ax) { initialize(); if (memberView==null) { @@ -1407,4 +1415,5 @@ public final class LazyMethodGen { newAttributes[attributes.length] = attr; attributes = newAttributes; } + } |