]> source.dussan.org Git - aspectj.git/commitdiff
Fix for Bug 82062: WeaveMessage should provide more information
authoraclement <aclement>
Tue, 4 Jan 2005 13:15:57 +0000 (13:15 +0000)
committeraclement <aclement>
Tue, 4 Jan 2005 13:15:57 +0000 (13:15 +0000)
(Bug and fix from Martin Lippert)

bridge/src/org/aspectj/bridge/WeaveMessage.java
weaver/src/org/aspectj/weaver/Advice.java
weaver/src/org/aspectj/weaver/Shadow.java
weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java

index 3f2e722978a7eb7112a12af9a5bf8a5fae5b66ec..3dfd82fcafa76433a6dabf68ef1b9f3fd02a52d4 100644 (file)
@@ -33,11 +33,35 @@ public class WeaveMessage extends Message {
          new WeaveMessageKind(5,"Softening exceptions in type '%1' (%2) as defined by aspect '%3' (%4)");
 
 
+       private String affectedtypename;
+       private String aspectname;
+
+
     // private ctor - use the static factory method
-       private WeaveMessage(String message) {
+       private WeaveMessage(String message, String affectedtypename, String aspectname) {
                super(message, IMessage.WEAVEINFO, null, null);
+               this.affectedtypename = affectedtypename;
+               this.aspectname = aspectname;
        }    
 
+    /**
+     * Static helper method for constructing weaving messages.
+     * @param kind what kind of message (e.g. declare parents)
+     * @param inserts inserts for the message (inserts are marked %n in the message)
+     * @return new weaving message
+     */
+       public static WeaveMessage constructWeavingMessage(
+         WeaveMessageKind kind,
+         String[] inserts) {
+               StringBuffer str = new StringBuffer(kind.getMessage());
+               int pos = -1;
+               while ((pos=new String(str).indexOf("%"))!=-1) {
+                       int n = Character.getNumericValue(str.charAt(pos+1));
+                       str.replace(pos,pos+2,inserts[n-1]);
+               }
+               return new WeaveMessage(str.toString(), null, null);
+       }
+       
     /**
      * Static helper method for constructing weaving messages.
      * @param kind what kind of message (e.g. declare parents)
@@ -48,17 +72,31 @@ public class WeaveMessage extends Message {
      */
        public static WeaveMessage constructWeavingMessage(
          WeaveMessageKind kind,
-         String[] inserts) {
+         String[] inserts,
+         String affectedtypename,
+         String aspectname) {
                StringBuffer str = new StringBuffer(kind.getMessage());
                int pos = -1;
                while ((pos=new String(str).indexOf("%"))!=-1) {
                        int n = Character.getNumericValue(str.charAt(pos+1));
                        str.replace(pos,pos+2,inserts[n-1]);
                }
-               return new WeaveMessage(str.toString());
+               return new WeaveMessage(str.toString(), affectedtypename, aspectname);
        }
        
+       /**
+        * @return Returns the aspectname.
+        */
+       public String getAspectname() {
+               return aspectname;
+       }
        
+       /**
+        * @return Returns the affectedtypename.
+        */
+       public String getAffectedtypename() {
+               return affectedtypename;
+       }
        
        public static class WeaveMessageKind {
        
index 1c8c92b98be946a9efebf03b58a9d7bf570caf9a..11b8f69c72b0350b40f5cc9e277a62ec1e4a50e8 100644 (file)
@@ -17,7 +17,6 @@ import java.util.Collections;
 import java.util.List;
 
 import org.aspectj.bridge.IMessage;
-import org.aspectj.bridge.ISourceLocation;
 import org.aspectj.weaver.patterns.AndPointcut;
 import org.aspectj.weaver.patterns.PerClause;
 import org.aspectj.weaver.patterns.Pointcut;
index c7c3309a66ab07d303e2b74ccfb7c1d400b420f5..07e32fc2390dd2282c50588a3964cd1a479a7282 100644 (file)
@@ -22,8 +22,11 @@ import java.util.List;
 import java.util.Set;
 
 import org.aspectj.asm.IRelationship;
-import org.aspectj.bridge.*;
+import org.aspectj.bridge.IMessage;
+import org.aspectj.bridge.ISourceLocation;
+import org.aspectj.bridge.Message;
 import org.aspectj.bridge.MessageUtil;
+import org.aspectj.bridge.WeaveMessage;
 import org.aspectj.lang.JoinPoint;
 import org.aspectj.util.PartialOrder;
 import org.aspectj.util.TypeSafeEnum;
@@ -416,14 +419,18 @@ public abstract class Shadow {
                        msg = WeaveMessage.constructWeavingMessage(
                          WeaveMessage.WEAVEMESSAGE_SOFTENS,
                            new String[]{advisedType,beautifyLocation(getSourceLocation()),
-                                                advisingType,beautifyLocation(munger.getSourceLocation())});
+                                                advisingType,beautifyLocation(munger.getSourceLocation())},
+                               advisedType,
+                               advisingType);
                } else {
                        boolean runtimeTest = ((BcelAdvice)advice).hasDynamicTests();
                    msg = WeaveMessage.constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_ADVISES,
-                         new String[]{ advisedType, beautifyLocation(getSourceLocation()),
+                               new String[]{ advisedType, beautifyLocation(getSourceLocation()),
                                            description,
                                            advisingType,beautifyLocation(munger.getSourceLocation()),
-                                           (runtimeTest?" [with runtime test]":"")});
+                                           (runtimeTest?" [with runtime test]":"")},
+                                       advisedType,
+                                       advisingType);
                                         // Boolean.toString(runtimeTest)});
                }
                getIWorld().getMessageHandler().handleMessage(msg);
index 219c91fc4e064d6f1e22ef0d1bdbdeab36996d29..4d5e68be3518db211597a7c35d50714d35e02ab1 100644 (file)
@@ -110,7 +110,8 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
                        if (parentTM.getNewParent().isInterface()) {
                                        weaver.getWorld().getMessageHandler().handleMessage(WeaveMessage.constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_DECLAREPARENTSIMPLEMENTS,
                                        new String[]{weaver.getLazyClassGen().getType().getName(),
-                                       tName,parentTM.getNewParent().getName(),fName}));
+                                       tName,parentTM.getNewParent().getName(),fName},
+                                       weaver.getLazyClassGen().getClassName(), getAspectType().getName()));
                        } else {
                                System.err.println("BANG, you need to fix this.  BcelTypeMunger");
                        }
@@ -119,7 +120,8 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
                        new String[]{weaver.getLazyClassGen().getType().getName(),
                                         tName,munger.getKind().toString().toLowerCase(),
                                         getAspectType().getName(),
-                                                fName+":'"+munger.getSignature()+"'"}));
+                                                fName+":'"+munger.getSignature()+"'"},
+                                                        weaver.getLazyClassGen().getClassName(), getAspectType().getName()));
                                // ??? If only type mungers knew their originating line numbers ...
                }       
                }
@@ -769,3 +771,4 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
                }
        }
 }
+               
\ No newline at end of file
index 43d86f992f94a6b745a9adfe808cd2b02a03ef58..d4e425b054625c550c5748faef120a0b69c2e648 100644 (file)
@@ -209,7 +209,7 @@ public class BcelWorld extends World implements Repository {
         }
        }
        
-       private BcelObjectType makeBcelObjectType(ResolvedTypeX.Name resolvedTypeX, JavaClass jc, boolean exposedToWeaver) {
+       protected BcelObjectType makeBcelObjectType(ResolvedTypeX.Name resolvedTypeX, JavaClass jc, boolean exposedToWeaver) {
                BcelObjectType ret = new BcelObjectType(resolvedTypeX, jc, exposedToWeaver);
                resolvedTypeX.setDelegate(ret);
                return ret;