}
}
+ public Member getRealEnclosingCodeSignature() {
+ return enclosingMethod.getMemberView();
+ }
+
+ // public Member getEnclosingCodeSignatureForModel() {
+ // if (getKind().isEnclosingKind()) {
+ // return getSignature();
+ // } else if (getKind() == Shadow.PreInitialization) {
+ // // PreInit doesn't enclose code but its signature
+ // // is correctly the signature of the ctor.
+ // return getSignature();
+ // } else if (enclosingShadow == null) {
+ // return getEnclosingMethod().getMemberView();
+ // } else {
+ // if (enclosingShadow.getKind() == Shadow.MethodExecution && enclosingMethod.getEffectiveSignature() != null) {
+ //
+ // } else {
+ // return enclosingShadow.getSignature();
+ // }
+ // }
+ // }
+
private InstructionList makeArgsObjectArray() {
InstructionFactory fact = getFactory();
BcelVar arrayVar = genTempVar(UnresolvedType.OBJECTARRAY);
import org.aspectj.weaver.ShadowMunger;
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.World;
+import org.aspectj.weaver.bcel.BcelShadow;
import org.aspectj.weaver.patterns.DeclareErrorOrWarning;
import org.aspectj.weaver.patterns.Pointcut;
protected static IProgramElement getNode(AsmManager model, Shadow shadow) {
Member enclosingMember = shadow.getEnclosingCodeSignature();
+ // This variant will not be tricked by ITDs that would report they are in the target type already.
+ // This enables us to discover the ITD declaration (in the aspect) and advise it appropriately.
+
+ // Have to be smart here, for a code node within an ITD we want to lookup the declaration of the
+ // ITD in the aspect in order to add the code node at the right place - and not lookup the
+ // ITD as it applies in some target type. Due to the use of effectiveSignature we will find
+ // that shadow.getEnclosingCodeSignature() will return a member representing the ITD as it will
+ // appear in the target type. So here, we do an extra bit of analysis to make sure we
+ // do the right thing in the ITD case.
+ IProgramElement enclosingNode = null;
+ if (shadow instanceof BcelShadow) {
+ Member actualEnclosingMember = ((BcelShadow) shadow).getRealEnclosingCodeSignature();
+
+ UnresolvedType type = enclosingMember.getDeclaringType();
+ UnresolvedType actualType = actualEnclosingMember.getDeclaringType();
+
+ // if these are not the same, it is an ITD and we need to use the latter to lookup
+ if (type.equals(actualType)) {
+ enclosingNode = lookupMember(model.getHierarchy(), shadow.getEnclosingType(), enclosingMember);
+ } else {
+ enclosingNode = lookupMember(model.getHierarchy(), shadow.getEnclosingType(), actualEnclosingMember);
+ }
+ } else {
+ enclosingNode = lookupMember(model.getHierarchy(), shadow.getEnclosingType(), enclosingMember);
+ }
- IProgramElement enclosingNode = lookupMember(model.getHierarchy(), enclosingMember);
if (enclosingNode == null) {
Lint.Kind err = shadow.getIWorld().getLint().shadowNotInStructure;
if (err.isEnabled()) {
return findMemberInClass(classNode, member);
}
+ protected static IProgramElement lookupMember(IHierarchy model, UnresolvedType declaringType, Member member) {
+ IProgramElement classNode = model.findElementForType(declaringType.getPackageName(), declaringType.getClassName());
+ return findMemberInClass(classNode, member);
+ }
+
protected static IProgramElement findMemberInClass(IProgramElement classNode, Member member) {
if (classNode == null)
return null; // XXX remove this check