]> source.dussan.org Git - aspectj.git/commitdiff
246125: removed last Asm dependency from org.aspectj.weaver (world model ref). Remov...
authoraclement <aclement>
Mon, 20 Oct 2008 23:33:48 +0000 (23:33 +0000)
committeraclement <aclement>
Mon, 20 Oct 2008 23:33:48 +0000 (23:33 +0000)
12 files changed:
weaver/src/org/aspectj/weaver/AbstractReferenceTypeDelegate.java
weaver/src/org/aspectj/weaver/NameMangler.java
weaver/src/org/aspectj/weaver/ReferenceType.java
weaver/src/org/aspectj/weaver/ReferenceTypeDelegate.java
weaver/src/org/aspectj/weaver/World.java
weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java
weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java

index 17bdf7f6a3e637903b0de214d22050b17b1c2aad..52d0ade355d96a7cbfec69187de4e969d085242c 100644 (file)
@@ -121,4 +121,8 @@ public abstract class AbstractReferenceTypeDelegate implements ReferenceTypeDele
                return ret;
        }
 
+       public boolean copySourceContext() {
+               return true;
+       }
+
 }
\ No newline at end of file
index 6aa483ed478a3527cd7396e24be190dc7275e189..5da734a6239e36385acf1b7ab21a6e2e0a24956d 100644 (file)
@@ -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();
        }
 
index d1669abec1813f1f7deb67c0e9d40b7af4d072a6..8961e21946645fc8dbfe672b7faa0ebeb8245201 100644 (file)
@@ -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;
index a19d5ca6782f25efbf23de758abe45adf053e7ea..ec9d83915c9e83a1080bee1cd261c3604a13ae93 100644 (file)
@@ -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
index 25f8cc73bcf14286a4955860825ba91c72a7e135..7cba4d4b850ecd6fa425755d8baa4b2244b1d2ab 100644 (file)
@@ -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;
        }
 
index 372dcb73522c08f4c61a5071c1ae6d2a91bf8557..6a55bbd0b4c2f60dfceb07836ed3ff927bfacd1a 100644 (file)
@@ -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);
index 2940c7bf0d45c2e8319e30da1186709b36c31fe8..d999336f0e4e50681dc3a48a6a8299937628de0a 100644 (file)
@@ -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;
+       }
 }
index 20110f5174df4f7381d70b00e3efbb2cb7db9494..d6eb937812c77f83fba11122c20457528df74f0f 100644 (file)
@@ -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);
 
index de8cf3a3c827007d5e8e01a3f164d80e2fc0ee0d..853282f4b700451352de0ed2852f75f27680a73a 100644 (file)
@@ -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
index eec8b5eac2827f8eeac9770058aec40f00ee9a00..e1c2555eb5c92c521d6b6c367f69fa474eb0ffa3 100644 (file)
@@ -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(
index d5d36f9932322562de58def7115f20f8df04022f..f59e894bdfc74f3fd58877e60170ba014d3e353d 100644 (file)
@@ -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
index 55fc1fa6f0edf270fc5ac174eb14b573b3b4d422..b96611a0544d70e7c9326beec12ceb26480678ae 100644 (file)
@@ -436,4 +436,7 @@ public class ReflectionBasedReferenceTypeDelegate implements ReferenceTypeDelega
                return SourceContextImpl.UNKNOWN_SOURCE_CONTEXT;
        }
 
+       public boolean copySourceContext() {
+               return true;
+       }
 }