From: acolyer Date: Thu, 1 Sep 2005 19:47:37 +0000 (+0000) Subject: fix for pr98290, 'matches declare' relationship not correctly created because offset... X-Git-Tag: preDefaultReweavable~128 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=619f8bc764e127d4f43ece87ae0e858f7329ec9e;p=aspectj.git fix for pr98290, 'matches declare' relationship not correctly created because offset location missing. --- 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; } + }