]> source.dussan.org Git - aspectj.git/commitdiff
Bug 150487 "Tracing and Logging Framework" (new/fixed trace points)
authormwebster <mwebster>
Wed, 16 Aug 2006 14:54:03 +0000 (14:54 +0000)
committermwebster <mwebster>
Wed, 16 Aug 2006 14:54:03 +0000 (14:54 +0000)
loadtime/src/org/aspectj/weaver/loadtime/Aj.java
weaver/src/org/aspectj/weaver/CrosscuttingMembersSet.java
weaver/src/org/aspectj/weaver/UnresolvedType.java
weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java

index 97dbd4d827010a746d7909386619ed8ec7b3d614..f7afb1c6fe1e28ff94f520228a468bc3693b9c7e 100644 (file)
@@ -36,7 +36,7 @@ public class Aj implements ClassPreProcessor {
        
        
        public Aj(IWeavingContext context){
-               if (trace.isTraceEnabled()) trace.enter("<init>",this,new Object[] {context});
+               if (trace.isTraceEnabled()) trace.enter("<init>",this,new Object[] {context, getClass().getClassLoader()});
                this.weavingContext = context;
                if (trace.isTraceEnabled()) trace.exit("<init>");
        }
@@ -57,15 +57,15 @@ public class Aj implements ClassPreProcessor {
      * @return weaved bytes
      */
     public byte[] preProcess(String className, byte[] bytes, ClassLoader loader) {
-               if (trace.isTraceEnabled()) trace.enter("preProcess",this,new Object[] {className,bytes,loader});
        
         //TODO AV needs to doc that
         if (loader == null || className == null) {
             // skip boot loader or null classes (hibernate)
-               if (trace.isTraceEnabled()) trace.exit("preProcess",bytes);
             return bytes;
         }
 
+        if (trace.isTraceEnabled()) trace.enter("preProcess",this,new Object[] {className, bytes, loader, Thread.currentThread().getContextClassLoader()});
+
         try {
                synchronized (loader) {
                 WeavingAdaptor weavingAdaptor = WeaverContainer.getWeaver(loader, weavingContext);
@@ -73,15 +73,16 @@ public class Aj implements ClassPreProcessor {
                        if (trace.isTraceEnabled()) trace.exit("preProcess");
                        return bytes;
                 }
-                       if (trace.isTraceEnabled()) trace.exit("preProcess",bytes);
-                return weavingAdaptor.weaveClass(className, bytes);
+                byte[] newBytes = weavingAdaptor.weaveClass(className, bytes);
+                       if (trace.isTraceEnabled()) trace.exit("preProcess",newBytes);
+                return newBytes;
                        }
-        } catch (Exception t) {
-               trace.error("preProcess",t);
+        } catch (Exception ex) {
+               trace.error("preProcess",ex);
             //FIXME AV wondering if we should have the option to fail (throw runtime exception) here
             // would make sense at least in test f.e. see TestHelper.handleMessage()
-            t.printStackTrace();
-               if (trace.isTraceEnabled()) trace.exit("preProcess",bytes);
+            ex.printStackTrace();
+               if (trace.isTraceEnabled()) trace.exit("preProcess",ex);
             return bytes;
         }
     }
index b456c7d9daebe9208fab771ff681f5167685399b..55d46b64263454a33e1e5f320b25bbeb33255aab 100644 (file)
@@ -25,6 +25,8 @@ import org.aspectj.asm.AsmManager;
 import org.aspectj.weaver.patterns.CflowPointcut;
 import org.aspectj.weaver.patterns.DeclareParents;
 import org.aspectj.weaver.patterns.IVerificationRequired;
+import org.aspectj.weaver.tools.Trace;
+import org.aspectj.weaver.tools.TraceFactory;
 
 /**
  * This holds on to all CrosscuttingMembers for a world.  It handles 
@@ -50,8 +52,14 @@ public class CrosscuttingMembersSet {
 
        private List /*IVerificationRequired*/ verificationList = null; // List of things to be verified once the type system is 'complete'
        
+       private static Trace trace = TraceFactory.getTraceFactory().getTrace(CrosscuttingMembersSet.class);
+       
        public CrosscuttingMembersSet(World world) {
+               trace.enter("<init>",this,world);
+
                this.world = world;
+
+               trace.exit("<init>");
        }
 
        public boolean addOrReplaceAspect(ResolvedType aspectType) {
@@ -63,6 +71,8 @@ public class CrosscuttingMembersSet {
         *                      XXX for efficiency we will need a richer representation than this
         */
        public boolean addOrReplaceAspect(ResolvedType aspectType, boolean inWeavingPhase) {
+               trace.enter("addOrReplaceAspect",this,new Object[] {aspectType,new Boolean(inWeavingPhase)});
+               
                boolean change = false;
                CrosscuttingMembers xcut = (CrosscuttingMembers)members.get(aspectType);
                if (xcut == null) {
@@ -92,6 +102,8 @@ public class CrosscuttingMembersSet {
                        change = change || ancestorChange;
                }
                changedSinceLastReset = changedSinceLastReset || change;
+
+               trace.exit("addOrReplaceAspect",change);
                return change;
        }
     
index 49834e148e160809164432156ca460bbd84ee57c..817a07e1d84b4efa3da4b2aaca89f8fe7a09d9fe 100644 (file)
@@ -22,6 +22,7 @@ import java.util.Map;
 import org.aspectj.apache.bcel.classfile.GenericSignatureParser;
 import org.aspectj.apache.bcel.classfile.Signature;
 import org.aspectj.apache.bcel.classfile.Signature.ClassSignature;
+import org.aspectj.weaver.tools.Traceable;
 
 /**
  * A UnresolvedType represents a type to the weaver. It has a basic signature that knows 
@@ -93,7 +94,7 @@ import org.aspectj.apache.bcel.classfile.Signature.ClassSignature;
  * The wildcard ? extends Foo has signature +LFoo;
  * The wildcard ? super Foo has signature -LFoo;
  */
-public class UnresolvedType implements TypeVariableDeclaringElement {
+public class UnresolvedType implements Traceable, TypeVariableDeclaringElement {
 
        // common types referred to by the weaver
     public static final UnresolvedType[] NONE         = new UnresolvedType[0];
@@ -917,6 +918,10 @@ public class UnresolvedType implements TypeVariableDeclaringElement {
                }
                return null;
        }
+
+       public String toTraceString() {
+               return getClass().getName() + "[" + getName() + "]";
+       }
        
 }
 
index feae53d0fcaf792e9ff85a993a00c79f9419a754..0a13be53d66720d01cfff045074c90c1f531a272 100644 (file)
@@ -1324,6 +1324,8 @@ public class BcelWeaver implements IWeaver {
 
     private void weaveAndNotify(UnwovenClassFile classFile, BcelObjectType classType,
                                    IWeaveRequestor requestor) throws IOException {
+       trace.enter("weaveAndNotify",this,new Object[] {classFile,classType,requestor});
+       
        ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_TYPE, classType.getResolvedTypeX().getName());
        LazyClassGen clazz = weaveWithoutDump(classFile,classType);
        classType.finishedWith();
@@ -1338,6 +1340,8 @@ public class BcelWeaver implements IWeaver {
                }
                classType.weavingCompleted();
                CompilationAndWeavingContext.leavingPhase(tok);
+               
+               trace.exit("weaveAndNotify");
     }
     
        /** helper method - will return NULL if the underlying delegate is an EclipseSourceType and not a BcelObjectType */