From e8b6bde2173e74a5969162aee2de59eee9476456 Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 15 Nov 2005 14:34:45 +0000 Subject: [PATCH] Matthews patches for 115275 --- .../loadtime/ClassLoaderWeavingAdaptor.java | 17 +++++- tests/ltw/aop-aspectsinclude.xml | 5 ++ .../ltw/aop-aspectsincludewithlintwarning.xml | 8 +++ .../systemtest/ajc150/ltw/LTWTests.java | 8 +++ .../systemtest/ajc150/ltw/ltw-tests.xml | 56 +++++++++++++++++++ weaver/src/org/aspectj/weaver/Lint.java | 3 + .../aspectj/weaver/XlintDefault.properties | 2 + .../aspectj/weaver/tools/WeavingAdaptor.java | 5 ++ 8 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 tests/ltw/aop-aspectsinclude.xml create mode 100644 tests/ltw/aop-aspectsincludewithlintwarning.xml diff --git a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java index 3ca6d69cf..bbbbc7bfa 100644 --- a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java +++ b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java @@ -19,9 +19,11 @@ import org.aspectj.bridge.Message; import org.aspectj.bridge.MessageUtil; import org.aspectj.util.LangUtil; import org.aspectj.weaver.ICrossReferenceHandler; +import org.aspectj.weaver.Lint; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.UnresolvedType; import org.aspectj.weaver.World; +import org.aspectj.weaver.Lint.Kind; import org.aspectj.weaver.bcel.BcelWeaver; import org.aspectj.weaver.bcel.BcelWorld; import org.aspectj.weaver.bcel.Utility; @@ -175,9 +177,8 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor { info("no configuration found. Disabling weaver for class loader " + getClassLoaderName(loader)); } } catch (Exception e) { - weaver.getWorld().getMessageHandler().handleMessage( - new Message("Register definition failed", IMessage.WARNING, e, null) - ); + enabled = false;// will allow very fast skip in shouldWeave() + warn("register definition failed",e); } } @@ -284,6 +285,12 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor { } } + protected void lint (String name, String[] infos) { + Lint lint = bcelWorld.getLint(); + Kind kind = lint.getLintKind(name); + kind.signal(infos,null,null); + } + /** * Register the aspect, following include / exclude rules * @@ -312,6 +319,10 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor { namespace = namespace.append(";"+aspectClassName); } } + else { +// warn("aspect excluded: " + aspectClassName); + lint("aspectExcludedByConfiguration", new String[] { aspectClassName, getClassLoaderName(loader) }); + } } } diff --git a/tests/ltw/aop-aspectsinclude.xml b/tests/ltw/aop-aspectsinclude.xml new file mode 100644 index 000000000..95f73f611 --- /dev/null +++ b/tests/ltw/aop-aspectsinclude.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/ltw/aop-aspectsincludewithlintwarning.xml b/tests/ltw/aop-aspectsincludewithlintwarning.xml new file mode 100644 index 000000000..8939234ab --- /dev/null +++ b/tests/ltw/aop-aspectsincludewithlintwarning.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/src/org/aspectj/systemtest/ajc150/ltw/LTWTests.java b/tests/src/org/aspectj/systemtest/ajc150/ltw/LTWTests.java index 66eb92c68..ffb52a905 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ltw/LTWTests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/ltw/LTWTests.java @@ -57,6 +57,14 @@ public class LTWTests extends org.aspectj.testing.XMLBasedAjcTestCase { runTest("Use abstract aspect for ITD using aop.xml"); } + public void testAspectsInclude () { + runTest("Ensure a subset of inherited aspects is used for weaving"); + } + + public void testAspectsIncludeWithLintWarning () { + runTest("Ensure weaver lint warning issued when an aspect is not used for weaving"); + } + /* * Allow system properties to be set and restored * TODO maw move to XMLBasedAjcTestCase or RunSpec diff --git a/tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml b/tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml index 6a8fe1881..69eff31ee 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml @@ -158,4 +158,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/weaver/src/org/aspectj/weaver/Lint.java b/weaver/src/org/aspectj/weaver/Lint.java index d0b22e47c..e8b237079 100644 --- a/weaver/src/org/aspectj/weaver/Lint.java +++ b/weaver/src/org/aspectj/weaver/Lint.java @@ -102,6 +102,9 @@ public class Lint { public final Kind noExplicitConstructorCall = new Kind("noExplicitConstructorCall","inter-type constructor does not contain explicit constructor call: field initializers in the target type will not be executed"); + public final Kind aspectExcludedByConfiguration = + new Kind("aspectExcludedByConfiguration","aspect {0} exluded for class loader {1}"); + public Lint(World world) { this.world = world; } diff --git a/weaver/src/org/aspectj/weaver/XlintDefault.properties b/weaver/src/org/aspectj/weaver/XlintDefault.properties index da3856a79..bb40c00cd 100644 --- a/weaver/src/org/aspectj/weaver/XlintDefault.properties +++ b/weaver/src/org/aspectj/weaver/XlintDefault.properties @@ -30,3 +30,5 @@ elementAlreadyAnnotated = warning runtimeExceptionNotSoftened = warning uncheckedArgument = warning noExplicitConstructorCall = warning + +aspectExcludedByConfiguration = ignore diff --git a/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java b/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java index b59ec5564..ea7590273 100644 --- a/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java +++ b/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java @@ -31,6 +31,7 @@ import java.util.StringTokenizer; import org.aspectj.bridge.AbortException; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.IMessageHandler; +import org.aspectj.bridge.Message; import org.aspectj.bridge.MessageUtil; import org.aspectj.bridge.MessageWriter; import org.aspectj.bridge.IMessage.Kind; @@ -327,6 +328,10 @@ public class WeavingAdaptor { return MessageUtil.warn(messageHandler,message); } + protected boolean warn (String message, Throwable th) { + return messageHandler.handleMessage(new Message("Register definition failed", IMessage.WARNING, th, null)); + } + protected boolean error (String message) { return MessageUtil.error(messageHandler,message); } -- 2.39.5