From a1a700fc6eb8793d7bfa08a31a4529eb2e49b84c Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Sun, 29 Jan 2023 14:57:58 +0100 Subject: Implement source location matching for weave messages in XML tests WIP (work in progress). Closes #218. Signed-off-by: Alexander Kriegisch --- .../org/aspectj/weaver/bcel/BcelTypeMunger.java | 58 +++++++++++++++------- .../java/org/aspectj/weaver/bcel/BcelWorld.java | 32 ++++++++---- 2 files changed, 63 insertions(+), 27 deletions(-) (limited to 'weaver') diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelTypeMunger.java index 1d33f417e..9e5b4268c 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelTypeMunger.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelTypeMunger.java @@ -193,21 +193,36 @@ public class BcelTypeMunger extends ConcreteTypeMunger { NewParentTypeMunger parentTM = (NewParentTypeMunger) munger; if (parentTM.isMixin()) { weaver.getWorld() - .getMessageHandler() - .handleMessage( - WeaveMessage.constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_MIXIN, new String[] { - parentTM.getNewParent().getName(), fName, weaver.getLazyClassGen().getType().getName(), - tName }, weaver.getLazyClassGen().getClassName(), getAspectType().getName())); - } else { + .getMessageHandler() + .handleMessage( + WeaveMessage.constructWeavingMessage( + WeaveMessage.WEAVEMESSAGE_MIXIN, + new String[] { + parentTM.getNewParent().getName(), fName, + weaver.getLazyClassGen().getType().getName(), tName + }, + weaver.getLazyClassGen().getClassName(), getAspectType().getName(), + parentTM.getNewParent().getSourceLocation(), weaver.getLazyClassGen().getType().getSourceLocation() + ) + ); + } + else { if (parentTM.getNewParent().isInterface()) { weaver.getWorld() - .getMessageHandler() - .handleMessage( - WeaveMessage.constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_DECLAREPARENTSIMPLEMENTS, - new String[] { weaver.getLazyClassGen().getType().getName(), tName, - parentTM.getNewParent().getName(), fName }, weaver.getLazyClassGen() - .getClassName(), getAspectType().getName())); - } else { + .getMessageHandler() + .handleMessage( + WeaveMessage.constructWeavingMessage( + WeaveMessage.WEAVEMESSAGE_DECLAREPARENTSIMPLEMENTS, + new String[] { + weaver.getLazyClassGen().getType().getName(), tName, + parentTM.getNewParent().getName(), fName + }, + weaver.getLazyClassGen().getClassName(), getAspectType().getName(), + parentTM.getNewParent().getSourceLocation(), weaver.getLazyClassGen().getType().getSourceLocation() + ) + ); + } + else { weaver.getWorld() .getMessageHandler() .handleMessage( @@ -232,11 +247,18 @@ public class BcelTypeMunger extends ConcreteTypeMunger { fromString = fName; } weaver.getWorld() - .getMessageHandler() - .handleMessage( - WeaveMessage.constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_ITD, new String[] { - weaver.getLazyClassGen().getType().getName(), tName, kindString, getAspectType().getName(), - fromString }, weaver.getLazyClassGen().getClassName(), getAspectType().getName())); + .getMessageHandler() + .handleMessage( + WeaveMessage.constructWeavingMessage( + WeaveMessage.WEAVEMESSAGE_ITD, + new String[] { + weaver.getLazyClassGen().getType().getName(), tName, + kindString, getAspectType().getName(), fromString + }, + weaver.getLazyClassGen().getClassName(), getAspectType().getName(), + weaver.getLazyClassGen().getType().getSourceLocation(), getAspectType().getSourceLocation() + ) + ); } } diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWorld.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWorld.java index 745bd02b2..408b49870 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWorld.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWorld.java @@ -190,17 +190,31 @@ public class BcelWorld extends World implements Repository { String advisingType = advice.getConcreteAspect().getName(); Message msg = null; if (advice.getKind().equals(AdviceKind.Softener)) { - msg = WeaveMessage.constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_SOFTENS, new String[] { advisedType, - beautifyLocation(shadow.getSourceLocation()), advisingType, beautifyLocation(munger.getSourceLocation()) }, - advisedType, advisingType); - } else { + msg = WeaveMessage.constructWeavingMessage( + WeaveMessage.WEAVEMESSAGE_SOFTENS, + new String[] { + advisedType, beautifyLocation(shadow.getSourceLocation()), + advisingType, beautifyLocation(munger.getSourceLocation()) + }, + advisedType, advisingType, + shadow.getSourceLocation(), munger.getSourceLocation() + ); + } + else { boolean runtimeTest = advice.hasDynamicTests(); String joinPointDescription = shadow.toString(); - msg = WeaveMessage - .constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_ADVISES, - new String[] { joinPointDescription, advisedType, beautifyLocation(shadow.getSourceLocation()), - description, advisingType, beautifyLocation(munger.getSourceLocation()), - (runtimeTest ? " [with runtime test]" : "") }, advisedType, advisingType); + msg = WeaveMessage.constructWeavingMessage( + WeaveMessage.WEAVEMESSAGE_ADVISES, + new String[] { + joinPointDescription, + advisedType, beautifyLocation(shadow.getSourceLocation()), + description, + advisingType, beautifyLocation(munger.getSourceLocation()), + (runtimeTest ? " [with runtime test]" : "") + }, + advisedType, advisingType, + shadow.getSourceLocation(), munger.getSourceLocation() + ); // Boolean.toString(runtimeTest)}); } getMessageHandler().handleMessage(msg); -- cgit v1.2.3