From: aclement Date: Tue, 15 Sep 2009 19:41:37 +0000 (+0000) Subject: 124460 and refactoring X-Git-Tag: V1_6_6~32 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6164d9b825a2d9a4e40245c6acccf2a9395a62dd;p=aspectj.git 124460 and refactoring --- diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ShadowMunger.java b/org.aspectj.matcher/src/org/aspectj/weaver/ShadowMunger.java index a55c84fd0..f31655ed2 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ShadowMunger.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ShadowMunger.java @@ -16,9 +16,14 @@ import java.io.DataOutputStream; import java.io.File; import java.io.IOException; import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; import java.util.Map; +import java.util.Set; +import org.aspectj.bridge.IMessage; import org.aspectj.bridge.ISourceLocation; +import org.aspectj.bridge.MessageUtil; import org.aspectj.bridge.SourceLocation; import org.aspectj.util.PartialOrder; import org.aspectj.weaver.patterns.PerClause; @@ -67,7 +72,7 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH this.end = end; this.sourceContext = sourceContext; } - + /** * All overriding methods should call super */ @@ -75,8 +80,24 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH if (world.isXmlConfigured() && world.isAspectIncluded(declaringType)) { TypePattern scoped = world.getAspectScope(declaringType); if (scoped != null) { - boolean b = scoped.matches(shadow.getEnclosingType().resolve(world), TypePattern.STATIC).alwaysTrue(); + // Check the 'cached' exclusion map + Set excludedTypes = world.getExclusionMap().get(declaringType); + ResolvedType type = shadow.getEnclosingType().resolve(world); + if (excludedTypes!=null && excludedTypes.contains(type)) { + return false; + } + boolean b = scoped.matches(type, TypePattern.STATIC).alwaysTrue(); if (!b) { + if (!world.getMessageHandler().isIgnoring(IMessage.INFO)) { + world.getMessageHandler().handleMessage(MessageUtil.info("Type '"+type.getName()+"' not woven by aspect '"+declaringType.getName()+"' due to scope exclusion in XML definition")); + } + if (excludedTypes==null) { + excludedTypes = new HashSet(); + excludedTypes.add(type); + world.getExclusionMap().put(declaringType,excludedTypes); + } else { + excludedTypes.add(type); + } return false; } } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/World.java b/org.aspectj.matcher/src/org/aspectj/weaver/World.java index cdb01a1c8..dd61947a3 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/World.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/World.java @@ -1396,5 +1396,15 @@ public abstract class World implements Dump.INode { protected boolean isExpendable(ResolvedType type) { return (!type.equals(UnresolvedType.OBJECT) && (!type.isExposedToWeaver()) && (!type.isPrimitiveType())); } + + + // map from aspect > excluded types + // memory issue here? + private Map> exclusionMap = new HashMap>(); + + + public Map> getExclusionMap() { + return exclusionMap; + } } \ No newline at end of file