Browse Source

Matthews patches for 115275

tags/V1_5_0RC1
aclement 18 years ago
parent
commit
e8b6bde217

+ 14
- 3
loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java View File

@@ -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) });
}
}
}


+ 5
- 0
tests/ltw/aop-aspectsinclude.xml View File

@@ -0,0 +1,5 @@
<aspectj>
<aspects>
<include within="pakkage.*"/>
</aspects>
</aspectj>

+ 8
- 0
tests/ltw/aop-aspectsincludewithlintwarning.xml View File

@@ -0,0 +1,8 @@
<aspectj>
<aspects>
<include within="pakkage.*"/>
</aspects>

<weaver options="-Xlint:warning">
</weaver>
</aspectj>

+ 8
- 0
tests/src/org/aspectj/systemtest/ajc150/ltw/LTWTests.java View File

@@ -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

+ 56
- 0
tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml View File

@@ -158,4 +158,60 @@
</stderr>
</run>
</ajc-test>

<ajc-test dir="ltw"
title="Ensure a subset of inherited aspects is used for weaving"
keywords="aspects, include">
<compile
files="Main.java"
outjar="main.jar"
>
</compile>
<compile
classpath="main.jar"
files="Aspect1.aj, Aspect2.aj, pakkage/Aspect3.aj"
outjar="aspects.jar"
options="-outxml"
>
</compile>
<run class="Main" ltw="aop-aspectsinclude.xml">
<stdout>
<line text="Main.main"/>
<line text="Main.test1"/>
<line text="Main.test2"/>
</stdout>
<stderr>
<line text="pakkage.Aspect3.before_test2"/>
</stderr>
</run>
</ajc-test>

<ajc-test dir="ltw"
title="Ensure weaver lint warning issued when an aspect is not used for weaving"
keywords="aspects, include, lint">
<compile
files="Main.java"
outjar="main.jar"
>
</compile>
<compile
classpath="main.jar"
files="Aspect1.aj, Aspect2.aj, pakkage/Aspect3.aj"
outjar="aspects.jar"
options="-outxml"
>
</compile>
<run class="Main" ltw="aop-aspectsincludewithlintwarning.xml">
<stdout>
<line text="Main.main"/>
<line text="Main.test1"/>
<line text="Main.test2"/>
</stdout>
<stderr>
<line text="warning aspect Aspect1 exluded for class loader org.aspectj.weaver.loadtime.WeavingURLClassLoader [Xlint:aspectExcludedByConfiguration]"/>
<line text="warning aspect Aspect2 exluded for class loader org.aspectj.weaver.loadtime.WeavingURLClassLoader [Xlint:aspectExcludedByConfiguration]"/>
<line text="pakkage.Aspect3.before_test2"/>
</stderr>
</run>
</ajc-test>

+ 3
- 0
weaver/src/org/aspectj/weaver/Lint.java View File

@@ -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;
}

+ 2
- 0
weaver/src/org/aspectj/weaver/XlintDefault.properties View File

@@ -30,3 +30,5 @@ elementAlreadyAnnotated = warning
runtimeExceptionNotSoftened = warning
uncheckedArgument = warning
noExplicitConstructorCall = warning

aspectExcludedByConfiguration = ignore

+ 5
- 0
weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java View File

@@ -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);
}

Loading…
Cancel
Save