From 0370f564e76e1dc2338b22d1be266dc9edc8cdd1 Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 7 Mar 2006 17:08:42 +0000 Subject: [PATCH] 129163: more bits...: adjust compare to ignore some type mungers --- .../aspectj/weaver/CrosscuttingMembers.java | 40 +++++++++++++++++-- .../weaver/PrivilegedAccessMunger.java | 3 ++ .../aspectj/weaver/ResolvedTypeMunger.java | 15 +++++++ .../aspectj/weaver/bcel/BcelTypeMunger.java | 5 ++- 4 files changed, 58 insertions(+), 5 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java b/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java index 3b4ef2f8e..78fc05868 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.BcelTypeMunger; import org.aspectj.weaver.patterns.Declare; import org.aspectj.weaver.patterns.DeclareAnnotation; import org.aspectj.weaver.patterns.DeclareErrorOrWarning; @@ -240,12 +241,43 @@ public class CrosscuttingMembers { shadowMungers = other.shadowMungers; } } - // bug 129163: use set equality rather than list equality + + // bug 129163: use set equality rather than list equality and + // if we dont care about shadow mungers then ignore those + // typeMungers which are created to help with the implementation + // of shadowMungers Set theseTypeMungers = new HashSet(); - theseTypeMungers.addAll(typeMungers); Set otherTypeMungers = new HashSet(); - otherTypeMungers.addAll(other.typeMungers); - if (!theseTypeMungers.equals(otherTypeMungers)) { + if (!careAboutShadowMungers) { + for (Iterator iter = typeMungers.iterator(); iter.hasNext();) { + Object o = iter.next(); + if (o instanceof BcelTypeMunger) { + BcelTypeMunger typeMunger = (BcelTypeMunger) o; + if (!typeMunger.existsToSupportShadowMunging()) { + theseTypeMungers.add(typeMunger); + } + } else { + theseTypeMungers.add(o); + } + } + + for (Iterator iter = other.typeMungers.iterator(); iter.hasNext();) { + Object o = iter.next(); + if (o instanceof BcelTypeMunger) { + BcelTypeMunger typeMunger = (BcelTypeMunger) o; + if (!typeMunger.existsToSupportShadowMunging()) { + otherTypeMungers.add(typeMunger); + } + } else { + otherTypeMungers.add(o); + } + } + } else { + theseTypeMungers.addAll(typeMungers); + otherTypeMungers.addAll(other.typeMungers); + } + + if (!theseTypeMungers.equals(otherTypeMungers)) { changed = true; typeMungers = other.typeMungers; } diff --git a/weaver/src/org/aspectj/weaver/PrivilegedAccessMunger.java b/weaver/src/org/aspectj/weaver/PrivilegedAccessMunger.java index 21c7a1fc2..7296ae0ba 100644 --- a/weaver/src/org/aspectj/weaver/PrivilegedAccessMunger.java +++ b/weaver/src/org/aspectj/weaver/PrivilegedAccessMunger.java @@ -63,4 +63,7 @@ public class PrivilegedAccessMunger extends ResolvedTypeMunger { return result; } + public boolean existsToSupportShadowMunging() { + return true; + } } diff --git a/weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java b/weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java index 927b174be..f3d3c428a 100644 --- a/weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java +++ b/weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java @@ -407,5 +407,20 @@ public abstract class ResolvedTypeMunger { return false; } + /** + * Some type mungers are created purely to help with the implementation of shadow mungers. + * For example to support the cflow() pointcut we create a new cflow field in the aspect, and + * that is added via a BcelCflowCounterFieldAdder. + * + * During compilation we need to compare sets of type mungers, and if some only come into + * existence after the 'shadowy' type things have been processed, we need to ignore + * them during the comparison. + * + * Returning true from this method indicates the type munger exists to support 'shadowy' stuff - + * and so can be ignored in some comparison. + */ + public boolean existsToSupportShadowMunging() { + return false; + } } diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java index 5c4e918d8..540ad8099 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java @@ -1677,7 +1677,10 @@ public class BcelTypeMunger extends ConcreteTypeMunger { * and so can be ignored in some comparison. */ public boolean existsToSupportShadowMunging() { - return false; // Does this need to delegate to the ResolvedTypeMunger field held in the BcelTypeMunger? + if (munger != null) { + return munger.existsToSupportShadowMunging(); + } + return false; } } \ No newline at end of file -- 2.39.5