From: aclement Date: Mon, 20 Oct 2008 23:33:48 +0000 (+0000) Subject: 246125: removed last Asm dependency from org.aspectj.weaver (world model ref). Remov... X-Git-Tag: V1_6_3rc1~166 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=369e5fe5c1306b65454e27d30ed400138a9c12be;p=aspectj.git 246125: removed last Asm dependency from org.aspectj.weaver (world model ref). Removed bcelobjecttype dependency in ReferenceType. --- diff --git a/weaver/src/org/aspectj/weaver/AbstractReferenceTypeDelegate.java b/weaver/src/org/aspectj/weaver/AbstractReferenceTypeDelegate.java index 17bdf7f6a..52d0ade35 100644 --- a/weaver/src/org/aspectj/weaver/AbstractReferenceTypeDelegate.java +++ b/weaver/src/org/aspectj/weaver/AbstractReferenceTypeDelegate.java @@ -121,4 +121,8 @@ public abstract class AbstractReferenceTypeDelegate implements ReferenceTypeDele return ret; } + public boolean copySourceContext() { + return true; + } + } \ No newline at end of file diff --git a/weaver/src/org/aspectj/weaver/NameMangler.java b/weaver/src/org/aspectj/weaver/NameMangler.java index 6aa483ed4..5da734a62 100644 --- a/weaver/src/org/aspectj/weaver/NameMangler.java +++ b/weaver/src/org/aspectj/weaver/NameMangler.java @@ -14,8 +14,6 @@ package org.aspectj.weaver; import java.lang.reflect.Modifier; -import org.aspectj.weaver.bcel.LazyClassGen; - public class NameMangler { // public static final char[] AJC_DOLLAR_PREFIX = { 'a', 'j', 'c', '$' }; @@ -312,9 +310,9 @@ public class NameMangler { return enclosingType.getName() + "$AjcClosure" + index; } - public static String aroundCallbackMethodName(Member shadowSig, LazyClassGen enclosingType) { + public static String aroundCallbackMethodName(Member shadowSig, String suffixTag) { StringBuffer ret = new StringBuffer(); - ret.append(getExtractableName(shadowSig)).append("_aroundBody").append(enclosingType.getNewGeneratedNameTag()); + ret.append(getExtractableName(shadowSig)).append("_aroundBody").append(suffixTag); return ret.toString(); } diff --git a/weaver/src/org/aspectj/weaver/ReferenceType.java b/weaver/src/org/aspectj/weaver/ReferenceType.java index d1669abec..8961e2194 100644 --- a/weaver/src/org/aspectj/weaver/ReferenceType.java +++ b/weaver/src/org/aspectj/weaver/ReferenceType.java @@ -19,7 +19,6 @@ import java.util.List; import java.util.Map; import org.aspectj.bridge.ISourceLocation; -import org.aspectj.weaver.bcel.BcelObjectType; import org.aspectj.weaver.patterns.Declare; import org.aspectj.weaver.patterns.PerClause; @@ -703,7 +702,7 @@ public class ReferenceType extends ResolvedType { public void setDelegate(ReferenceTypeDelegate delegate) { // Don't copy from BcelObjectType to EclipseSourceType - the context may // be tidied (result null'd) after previous weaving - if (this.delegate != null && !(this.delegate instanceof BcelObjectType) + if (this.delegate != null && this.delegate.copySourceContext() && this.delegate.getSourceContext() != SourceContextImpl.UNKNOWN_SOURCE_CONTEXT) ((AbstractReferenceTypeDelegate) delegate).setSourceContext(this.delegate.getSourceContext()); this.delegate = delegate; diff --git a/weaver/src/org/aspectj/weaver/ReferenceTypeDelegate.java b/weaver/src/org/aspectj/weaver/ReferenceTypeDelegate.java index a19d5ca67..ec9d83915 100644 --- a/weaver/src/org/aspectj/weaver/ReferenceTypeDelegate.java +++ b/weaver/src/org/aspectj/weaver/ReferenceTypeDelegate.java @@ -17,9 +17,8 @@ import java.util.Collection; import org.aspectj.weaver.patterns.PerClause; /** - * Abstraction over a type - a reference type is Object and a descendant of - * Object, other types (int/etc) are considered primitive types. Abstract - * implementation provided by AbstractReferenceTypeDelegate. + * Abstraction over a type - a reference type is Object and a descendant of Object, other types (int/etc) are considered primitive + * types. Abstract implementation provided by AbstractReferenceTypeDelegate. */ public interface ReferenceTypeDelegate { @@ -101,4 +100,6 @@ public interface ReferenceTypeDelegate { public ResolvedType getOuterClass(); + public boolean copySourceContext(); + } \ No newline at end of file diff --git a/weaver/src/org/aspectj/weaver/World.java b/weaver/src/org/aspectj/weaver/World.java index 25f8cc73b..7cba4d4b8 100644 --- a/weaver/src/org/aspectj/weaver/World.java +++ b/weaver/src/org/aspectj/weaver/World.java @@ -28,13 +28,13 @@ import java.util.Properties; import java.util.Set; import java.util.WeakHashMap; -import org.aspectj.asm.AsmManager; import org.aspectj.bridge.IMessageHandler; import org.aspectj.bridge.ISourceLocation; import org.aspectj.bridge.Message; import org.aspectj.bridge.MessageUtil; import org.aspectj.bridge.IMessage.Kind; import org.aspectj.bridge.context.PinpointingMessageHandler; +import org.aspectj.util.IStructureModel; import org.aspectj.weaver.UnresolvedType.TypeKind; import org.aspectj.weaver.patterns.DeclarePrecedence; import org.aspectj.weaver.patterns.Pointcut; @@ -75,8 +75,8 @@ public abstract class World implements Dump.INode { /** All of the type and shadow mungers known to us */ private final CrosscuttingMembersSet crosscuttingMembersSet = new CrosscuttingMembersSet(this); - /** Model holds ASM relationships */ - private AsmManager model = null; + /** The structure model for the compilation */ + private IStructureModel model = null; /** for processing Xlint messages */ private Lint lint = new Lint(this); @@ -662,11 +662,11 @@ public abstract class World implements Dump.INode { return crosscuttingMembersSet; } - public AsmManager getModel() { + public IStructureModel getModel() { return model; } - public void setModel(AsmManager model) { + public void setModel(IStructureModel model) { this.model = model; } diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java index 372dcb735..6a55bbd0b 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java @@ -880,7 +880,7 @@ class BcelClassWeaver implements IClassWeaver { mg.addAnnotation(decaM.getAnnotationX()); AsmRelationshipProvider.getDefault().addDeclareAnnotationMethodRelationship(decaM.getSourceLocation(), - clazz.getName(), mg.getMemberView(), world.getModel());// getMethod()); + clazz.getName(), mg.getMemberView(), world.getModelAsAsmManager());// getMethod()); reportMethodCtorWeavingMessage(clazz, mg.getMemberView(), decaM, mg.getDeclarationLineNumber()); isChanged = true; modificationOccured = true; @@ -924,7 +924,8 @@ class BcelClassWeaver implements IClassWeaver { mg.addAnnotation(decaM.getAnnotationX()); AsmRelationshipProvider.getDefault().addDeclareAnnotationMethodRelationship( - decaM.getSourceLocation(), clazz.getName(), mg.getMemberView(), world.getModel());// getMethod()); + decaM.getSourceLocation(), clazz.getName(), mg.getMemberView(), + world.getModelAsAsmManager());// getMethod()); isChanged = true; modificationOccured = true; forRemoval.add(decaM); @@ -1102,7 +1103,7 @@ class BcelClassWeaver implements IClassWeaver { if (doesAlreadyHaveAnnotation(annotationHolder, itdIsActually, decaF, reportedErrors)) continue; // skip this one... annotationHolder.addAnnotation(decaF.getAnnotationX()); - AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(world.getModel(), + AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(world.getModelAsAsmManager(), decaF.getSourceLocation(), itdIsActually.getSourceLocation()); isChanged = true; modificationOccured = true; @@ -1125,7 +1126,7 @@ class BcelClassWeaver implements IClassWeaver { if (doesAlreadyHaveAnnotation(annotationHolder, itdIsActually, decaF, reportedErrors)) continue; // skip this one... annotationHolder.addAnnotation(decaF.getAnnotationX()); - AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(world.getModel(), + AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(world.getModelAsAsmManager(), decaF.getSourceLocation(), itdIsActually.getSourceLocation()); isChanged = true; modificationOccured = true; @@ -1160,7 +1161,7 @@ class BcelClassWeaver implements IClassWeaver { } annotationHolder.addAnnotation(decaMC.getAnnotationX()); isChanged = true; - AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(world.getModel(), + AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(world.getModelAsAsmManager(), decaMC.getSourceLocation(), unMangledInterMethod.getSourceLocation()); reportMethodCtorWeavingMessage(clazz, unMangledInterMethod, decaMC, -1); modificationOccured = true; @@ -1183,7 +1184,7 @@ class BcelClassWeaver implements IClassWeaver { continue; // skip this one... annotationHolder.addAnnotation(decaMC.getAnnotationX()); unMangledInterMethod.addAnnotation(decaMC.getAnnotationX()); - AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(world.getModel(), + AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(world.getModelAsAsmManager(), decaMC.getSourceLocation(), unMangledInterMethod.getSourceLocation()); isChanged = true; modificationOccured = true; @@ -1302,8 +1303,8 @@ class BcelClassWeaver implements IClassWeaver { } } - AsmRelationshipProvider.getDefault().addDeclareAnnotationFieldRelationship(world.getModel(), - decaF.getSourceLocation(), clazz.getName(), aBcelField);// .getFieldAsIs()); + AsmRelationshipProvider.getDefault().addDeclareAnnotationFieldRelationship( + world.getModelAsAsmManager(), decaF.getSourceLocation(), clazz.getName(), aBcelField);// .getFieldAsIs()); reportFieldAnnotationWeavingMessage(clazz, fields, fieldCounter, decaF); isChanged = true; modificationOccured = true; @@ -1337,8 +1338,8 @@ class BcelClassWeaver implements IClassWeaver { continue; // skip this one... } aBcelField.addAnnotation(decaF.getAnnotationX()); - AsmRelationshipProvider.getDefault().addDeclareAnnotationFieldRelationship(world.getModel(), - decaF.getSourceLocation(), clazz.getName(), aBcelField);// .getFieldAsIs()); + AsmRelationshipProvider.getDefault().addDeclareAnnotationFieldRelationship( + world.getModelAsAsmManager(), decaF.getSourceLocation(), clazz.getName(), aBcelField);// .getFieldAsIs()); isChanged = true; modificationOccured = true; forRemoval.add(decaF); diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java index 2940c7bf0..d999336f0 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java @@ -354,8 +354,8 @@ public class BcelObjectType extends AbstractReferenceTypeDelegate { typeMungers = new ArrayList(); declares = new ArrayList(); processAttributes(l, pointcuts, false); - l = AtAjAttributes.readAj5ClassAttributes(getResolvedTypeX().getWorld().getModel(), javaClass, getResolvedTypeX(), - getResolvedTypeX().getSourceContext(), msgHandler, isCodeStyleAspect); + l = AtAjAttributes.readAj5ClassAttributes(((BcelWorld) getResolvedTypeX().getWorld()).getModelAsAsmManager(), javaClass, + getResolvedTypeX(), getResolvedTypeX().getSourceContext(), msgHandler, isCodeStyleAspect); AjAttribute.Aspect deferredAspectAttribute = processAttributes(l, pointcuts, true); if (pointcuts.size() == 0) { @@ -935,4 +935,7 @@ public class BcelObjectType extends AbstractReferenceTypeDelegate { return hasBeenWoven; } + public boolean copySourceContext() { + return false; + } } diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java index 20110f517..d6eb93781 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java @@ -2119,11 +2119,13 @@ public class BcelShadow extends Shadow { // now generate the aroundBody method // eg. "private static final void method_aroundBody0(M, M, String, org.aspectj.lang.JoinPoint)" - LazyMethodGen extractedMethod = extractMethod(NameMangler.aroundCallbackMethodName(getSignature(), getEnclosingClass()), - Modifier.PRIVATE, munger); + LazyMethodGen extractedMethod = extractMethod(NameMangler.aroundCallbackMethodName(getSignature(), new Integer( + getEnclosingClass().getNewGeneratedNameTag()).toString()), Modifier.PRIVATE, munger); // now extract the advice into its own method - String adviceMethodName = NameMangler.aroundCallbackMethodName(getSignature(), getEnclosingClass()) + "$advice"; + String adviceMethodName = NameMangler.aroundCallbackMethodName(getSignature(), new Integer(getEnclosingClass() + .getNewGeneratedNameTag()).toString()) + + "$advice"; List argVarList = new ArrayList(); List proceedVarList = new ArrayList(); @@ -2668,8 +2670,8 @@ public class BcelShadow extends Shadow { int linenumber = getSourceLine(); // MOVE OUT ALL THE INSTRUCTIONS IN MY SHADOW INTO ANOTHER METHOD! - LazyMethodGen callbackMethod = extractMethod(NameMangler.aroundCallbackMethodName(getSignature(), getEnclosingClass()), 0, - munger); + LazyMethodGen callbackMethod = extractMethod(NameMangler.aroundCallbackMethodName(getSignature(), new Integer( + getEnclosingClass().getNewGeneratedNameTag()).toString()), 0, munger); BcelVar[] adviceVars = munger.getExposedStateAsBcelVars(true); diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java index de8cf3a3c..853282f4b 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java @@ -117,8 +117,8 @@ public class BcelTypeMunger extends ConcreteTypeMunger { } if (changed && worthReporting) { - AsmRelationshipProvider.getDefault().addRelationship(getWorld().getModel(), weaver.getLazyClassGen().getType(), munger, - getAspectType()); + AsmRelationshipProvider.getDefault().addRelationship(((BcelWorld) getWorld()).getModelAsAsmManager(), + weaver.getLazyClassGen().getType(), munger, getAspectType()); } // TAG: WeavingMessage diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java index eec8b5eac..e1c2555eb 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java @@ -1116,7 +1116,7 @@ public class BcelWeaver { if (world.getModel() != null /* AsmManager.isCreatingModel() */&& !isBatchWeave) { // remove all relationships where this file being woven is the // target of the relationship - world.getModel().removeRelationshipsTargettingThisType(classFile.getClassName()); + world.getModelAsAsmManager().removeRelationshipsTargettingThisType(classFile.getClassName()); } } @@ -1601,8 +1601,8 @@ public class BcelWeaver { boolean problemReported = verifyTargetIsOK(decA, onType, annoX, reportProblems); if (!problemReported) { - AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(world.getModel(), decA.getSourceLocation(), - onType.getSourceLocation()); + AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(world.getModelAsAsmManager(), + decA.getSourceLocation(), onType.getSourceLocation()); // TAG: WeavingMessage if (!getWorld().getMessageHandler().isIgnoring(IMessage.WEAVEINFO)) { getWorld().getMessageHandler().handleMessage( diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java b/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java index d5d36f993..f59e894bd 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java @@ -38,6 +38,7 @@ import org.aspectj.apache.bcel.util.ClassLoaderRepository; import org.aspectj.apache.bcel.util.ClassPath; import org.aspectj.apache.bcel.util.NonCachingClassLoaderRepository; import org.aspectj.apache.bcel.util.Repository; +import org.aspectj.asm.AsmManager; import org.aspectj.asm.IRelationship; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.IMessageHandler; @@ -129,7 +130,7 @@ public class BcelWorld extends World implements Repository { if (getModel() != null) { // System.err.println("munger: " + munger + " on " + this); - AsmRelationshipProvider.adviceMunger(getModel(), shadow, munger); + AsmRelationshipProvider.adviceMunger(getModelAsAsmManager(), shadow, munger); } } @@ -775,9 +776,13 @@ public class BcelWorld extends World implements Repository { } if (getModel() != null) { - AsmRelationshipProvider.checkerMunger(getModel(), shadow, checker); + AsmRelationshipProvider.checkerMunger(getModelAsAsmManager(), shadow, checker); } } + public AsmManager getModelAsAsmManager() { + return (AsmManager) getModel(); // For now... always an AsmManager in a bcel environment + } + } \ No newline at end of file diff --git a/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java b/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java index 55fc1fa6f..b96611a05 100644 --- a/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java +++ b/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java @@ -436,4 +436,7 @@ public class ReflectionBasedReferenceTypeDelegate implements ReferenceTypeDelega return SourceContextImpl.UNKNOWN_SOURCE_CONTEXT; } + public boolean copySourceContext() { + return true; + } }