From cd9fd1147b63c7a0df0c93307feae4dce7b19d4d Mon Sep 17 00:00:00 2001 From: aclement Date: Fri, 29 Sep 2006 14:21:57 +0000 Subject: [PATCH] test and fix for 158573 - incorrect 'adviceDidNotMatch' warning appears --- tests/multiIncremental/PR158573/base/A.aj | 8 ++++++++ tests/multiIncremental/PR158573/base/C.java | 7 +++++++ tests/multiIncremental/PR158573/inc1/A.aj | 8 ++++++++ .../tools/MultiProjectIncrementalTests.java | 18 ++++++++++++++++++ .../aspectj/weaver/CrosscuttingMembers.java | 16 +++++++++++++++- .../org/aspectj/weaver/bcel/BcelAdvice.java | 4 ++++ 6 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 tests/multiIncremental/PR158573/base/A.aj create mode 100644 tests/multiIncremental/PR158573/base/C.java create mode 100644 tests/multiIncremental/PR158573/inc1/A.aj diff --git a/tests/multiIncremental/PR158573/base/A.aj b/tests/multiIncremental/PR158573/base/A.aj new file mode 100644 index 000000000..748a37ac9 --- /dev/null +++ b/tests/multiIncremental/PR158573/base/A.aj @@ -0,0 +1,8 @@ +public aspect A { + + public static int i = 0; + + before() : execution(* *.*(..)) { + } + +} diff --git a/tests/multiIncremental/PR158573/base/C.java b/tests/multiIncremental/PR158573/base/C.java new file mode 100644 index 000000000..dfd672886 --- /dev/null +++ b/tests/multiIncremental/PR158573/base/C.java @@ -0,0 +1,7 @@ +public class C { + + public void m() { + + } + +} diff --git a/tests/multiIncremental/PR158573/inc1/A.aj b/tests/multiIncremental/PR158573/inc1/A.aj new file mode 100644 index 000000000..59f8507ce --- /dev/null +++ b/tests/multiIncremental/PR158573/inc1/A.aj @@ -0,0 +1,8 @@ +public aspect A { + + public static int i = 1; + + before() : execution(* *.*(..)) { + } + +} diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java index 5214c898f..9de1fbe79 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -1542,6 +1542,24 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa checkWasFullBuild(); } + public void testPR158573() { + IElementHandleProvider handleProvider = AsmManager.getDefault().getHandleProvider(); + AsmManager.getDefault().setHandleProvider(new JDTLikeHandleProvider()); + initialiseProject("PR158573"); + build("PR158573"); + List warnings = MyTaskListManager.getWarningMessages(); + assertTrue("There should be no warnings:\n"+warnings,warnings.isEmpty()); + alter("PR158573","inc1"); + build("PR158573"); + + checkWasntFullBuild(); + warnings = MyTaskListManager.getWarningMessages(); + assertTrue("There should be no warnings after changing the value of a " + + "variable:\n"+warnings,warnings.isEmpty()); + AsmManager.getDefault().setHandleProvider(handleProvider); + } + + // --- helper code --- /** diff --git a/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java b/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java index 258489e6e..9ceacacd1 100644 --- a/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java +++ b/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java @@ -20,6 +20,7 @@ import java.util.Iterator; import java.util.List; import java.util.Set; +import org.aspectj.weaver.bcel.BcelAdvice; import org.aspectj.weaver.bcel.BcelMethod; import org.aspectj.weaver.bcel.BcelTypeMunger; import org.aspectj.weaver.patterns.Declare; @@ -276,11 +277,24 @@ public class CrosscuttingMembers { changed = true; } + // bug 158573 - if there are no changes then preserve whether + // or not a particular shadowMunger has matched something. + if (!changed) { + for (Iterator iter = shadowMungers.iterator(); iter + .hasNext();) { + ShadowMunger munger = (ShadowMunger) iter.next(); + int i = other.shadowMungers.indexOf(munger); + ShadowMunger otherMunger = (ShadowMunger) other.shadowMungers.get(i); + if (munger instanceof BcelAdvice) { + ((BcelAdvice)otherMunger).setHasMatchedSomething(((BcelAdvice)munger).hasMatchedSomething()); + } + } + } // replace the existing list of shadowmungers with the // new ones in case anything like the sourcelocation has // changed, however, don't want this flagged as a change // which will force a full build - bug 134541 - shadowMungers = other.shadowMungers; + shadowMungers = other.shadowMungers; } // bug 129163: use set equality rather than list equality and diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java index 2fcd25e6d..05156b715 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java @@ -689,6 +689,10 @@ public class BcelAdvice extends Advice { return hasMatchedAtLeastOnce; } + public void setHasMatchedSomething(boolean hasMatchedSomething) { + hasMatchedAtLeastOnce = hasMatchedSomething; + } + protected void suppressLintWarnings(World inWorld) { if (suppressedLintKinds == null) { if (signature instanceof BcelMethod) { -- 2.39.5