aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2005-01-04 13:15:57 +0000
committeraclement <aclement>2005-01-04 13:15:57 +0000
commit98976598593e8a1f89e9628e8fc11c7822b8e3d4 (patch)
tree30e0ea7e81e896be0ffca52b61ca5a210d9c219b
parentc6e8e5a0d522eb5fc0f402c97d42d456516bfc6a (diff)
downloadaspectj-98976598593e8a1f89e9628e8fc11c7822b8e3d4.tar.gz
aspectj-98976598593e8a1f89e9628e8fc11c7822b8e3d4.zip
Fix for Bug 82062: WeaveMessage should provide more information
(Bug and fix from Martin Lippert)
-rw-r--r--bridge/src/org/aspectj/bridge/WeaveMessage.java44
-rw-r--r--weaver/src/org/aspectj/weaver/Advice.java1
-rw-r--r--weaver/src/org/aspectj/weaver/Shadow.java15
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java7
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelWorld.java2
5 files changed, 58 insertions, 11 deletions
diff --git a/bridge/src/org/aspectj/bridge/WeaveMessage.java b/bridge/src/org/aspectj/bridge/WeaveMessage.java
index 3f2e72297..3dfd82fca 100644
--- a/bridge/src/org/aspectj/bridge/WeaveMessage.java
+++ b/bridge/src/org/aspectj/bridge/WeaveMessage.java
@@ -33,32 +33,70 @@ 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)
+ * @param inserts inserts for the message (inserts are marked %n in the message)
* @param affectedtypename the type which is being advised/declaredUpon
* @param aspectname the aspect that defined the advice or declares
* @return new weaving 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 {
diff --git a/weaver/src/org/aspectj/weaver/Advice.java b/weaver/src/org/aspectj/weaver/Advice.java
index 1c8c92b98..11b8f69c7 100644
--- a/weaver/src/org/aspectj/weaver/Advice.java
+++ b/weaver/src/org/aspectj/weaver/Advice.java
@@ -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;
diff --git a/weaver/src/org/aspectj/weaver/Shadow.java b/weaver/src/org/aspectj/weaver/Shadow.java
index c7c3309a6..07e32fc23 100644
--- a/weaver/src/org/aspectj/weaver/Shadow.java
+++ b/weaver/src/org/aspectj/weaver/Shadow.java
@@ -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);
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
index 219c91fc4..4d5e68be3 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
@@ -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
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java b/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
index 43d86f992..d4e425b05 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
@@ -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;