From df01d2d711ab2988acf89f0ed0366864974c063d Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 25 Jan 2010 20:46:09 +0000 Subject: [PATCH] 298704 --- .../weaver/model/AsmRelationshipProvider.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/weaver/src/org/aspectj/weaver/model/AsmRelationshipProvider.java b/weaver/src/org/aspectj/weaver/model/AsmRelationshipProvider.java index b8a0c7ef8..c6f004afc 100644 --- a/weaver/src/org/aspectj/weaver/model/AsmRelationshipProvider.java +++ b/weaver/src/org/aspectj/weaver/model/AsmRelationshipProvider.java @@ -124,6 +124,7 @@ public class AsmRelationshipProvider { if (model == null) { return; } + if (World.createInjarHierarchy && isBinaryAspect(originatingAspect)) { createHierarchy(model, typeTransformer, originatingAspect); } @@ -140,6 +141,28 @@ public class AsmRelationshipProvider { if (closer != null) { sourceNode = closer; } + if (sourceNode == null) { + // This can be caused by the aspect defining the type munger actually being on the classpath and not the + // inpath or aspectpath. Rather than NPE at the next line, let's have another go at faulting it in. + // This inner loop is a small duplicate of the outer loop that attempts to find something closer than + // the type declaration + if (World.createInjarHierarchy) { + createHierarchy(model, typeTransformer, originatingAspect); + if (typeTransformer.getSourceLocation() != null && typeTransformer.getSourceLocation().getOffset() != -1 + && !isMixinRelated(typeTransformer)) { + sourceNode = model.getHierarchy().findElementForType(originatingAspect.getPackageName(), + originatingAspect.getClassName()); + IProgramElement closer2 = model.getHierarchy().findCloserMatchForLineNumber(sourceNode, + typeTransformer.getSourceLocation().getLine()); + if (closer2 != null) { + sourceNode = closer2; + } + } else { + sourceNode = model.getHierarchy().findElementForType(originatingAspect.getPackageName(), + originatingAspect.getClassName()); + } + } + } sourceHandle = sourceNode.getHandleIdentifier(); } else { sourceNode = model.getHierarchy().findElementForType(originatingAspect.getPackageName(), -- 2.39.5