From 2c8190702e95baf0489e384767c816f30d870c86 Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 30 Nov 2005 17:23:35 +0000 Subject: [PATCH] implementation of new xlint: pr111667 --- .../systemtest/ajc150/Ajc150Tests.java | 2 +- .../org/aspectj/systemtest/ajc150/ajc150.xml | 3 +- weaver/src/org/aspectj/weaver/Lint.java | 3 + weaver/src/org/aspectj/weaver/Shadow.java | 60 +++++++++++++++++++ weaver/src/org/aspectj/weaver/World.java | 7 +++ .../aspectj/weaver/XlintDefault.properties | 2 + 6 files changed, 75 insertions(+), 2 deletions(-) diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index 603cc05b3..b7113cd44 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -81,7 +81,7 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void testVarargsITD_pr110906() { runTest("ITD varargs problem");} public void testBadRenderer_pr86903() { runTest("bcelrenderer bad");} - //public void testLintForAdviceSorting_pr111667() { runTest("lint for advice sorting");} + public void testLintForAdviceSorting_pr111667() { runTest("lint for advice sorting");} public void testIncompatibleClassChangeError_pr113630_1() {runTest("IncompatibleClassChangeError - errorscenario");} public void testIncompatibleClassChangeError_pr113630_2() {runTest("IncompatibleClassChangeError - workingscenario");} diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index 027648cf8..1b24aa992 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -87,7 +87,8 @@ - + + diff --git a/weaver/src/org/aspectj/weaver/Lint.java b/weaver/src/org/aspectj/weaver/Lint.java index 5380ecfdf..92dc373c5 100644 --- a/weaver/src/org/aspectj/weaver/Lint.java +++ b/weaver/src/org/aspectj/weaver/Lint.java @@ -108,6 +108,9 @@ public class Lint { public final Kind aspectExcludedByConfiguration = new Kind("aspectExcludedByConfiguration","aspect {0} exluded for class loader {1}"); + public final Kind unorderedAdviceAtShadow = + new Kind("unorderedAdviceAtShadow","at this shadow {0} no precedence is specified between advice applying from aspect {1} and aspect {2}"); + // there are a lot of messages in the cant find type family - I'm defining an umbrella lint warning that // allows a user to control their severity (for e.g. ltw or binary weaving) public final Kind cantFindType = diff --git a/weaver/src/org/aspectj/weaver/Shadow.java b/weaver/src/org/aspectj/weaver/Shadow.java index 5de7a60ef..4dc7a9703 100644 --- a/weaver/src/org/aspectj/weaver/Shadow.java +++ b/weaver/src/org/aspectj/weaver/Shadow.java @@ -406,7 +406,12 @@ public abstract class Shadow { } private void sortMungers() { + List sorted = PartialOrder.sort(mungers); + + // Bunch of code to work out whether to report xlints for advice that isn't ordered at this Joinpoint + possiblyReportUnorderedAdvice(sorted); + if (sorted == null) { // this means that we have circular dependencies for (Iterator i = mungers.iterator(); i.hasNext(); ) { @@ -418,6 +423,61 @@ public abstract class Shadow { } mungers = sorted; } + + // not quite optimal... but the xlint is ignore by default + private void possiblyReportUnorderedAdvice(List sorted) { + if (sorted!=null && getIWorld().getLint().unorderedAdviceAtShadow.isEnabled() && mungers.size()>1) { + + // Stores a set of strings of the form 'aspect1:aspect2' which indicates there is no + // precedence specified between the two aspects at this shadow. + Set clashingAspects = new HashSet(); + int max = mungers.size(); + + // Compare every pair of advice mungers + for (int i = max-1; i >=0; i--) { + for (int j=0; j