]> source.dussan.org Git - aspectj.git/commitdiff
test and fix for 158573 - incorrect 'adviceDidNotMatch' warning appears
authoraclement <aclement>
Fri, 29 Sep 2006 14:21:57 +0000 (14:21 +0000)
committeraclement <aclement>
Fri, 29 Sep 2006 14:21:57 +0000 (14:21 +0000)
tests/multiIncremental/PR158573/base/A.aj [new file with mode: 0644]
tests/multiIncremental/PR158573/base/C.java [new file with mode: 0644]
tests/multiIncremental/PR158573/inc1/A.aj [new file with mode: 0644]
tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java
weaver/src/org/aspectj/weaver/CrosscuttingMembers.java
weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java

diff --git a/tests/multiIncremental/PR158573/base/A.aj b/tests/multiIncremental/PR158573/base/A.aj
new file mode 100644 (file)
index 0000000..748a37a
--- /dev/null
@@ -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 (file)
index 0000000..dfd6728
--- /dev/null
@@ -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 (file)
index 0000000..59f8507
--- /dev/null
@@ -0,0 +1,8 @@
+public aspect A {
+       
+       public static int i = 1;
+       
+       before() : execution(* *.*(..)) {
+       }
+       
+}
index 5214c898f67a5a2ff8899f6dd4aae3d737a0fd6f..9de1fbe796a4597b259d37de3d4c26285589e66d 100644 (file)
@@ -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 ---
        
        /**
index 258489e6e76915d541f5c5ed287250e51380a753..9ceacacd1ad98fd0e16986f50413a9c5e48b35e2 100644 (file)
@@ -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
index 2fcd25e6d44d51309eeb10fa71ccb9c2aec3e898..05156b7156b1ad1086f69d859221f56d3864b18f 100644 (file)
@@ -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) {