From: aclement Date: Thu, 10 Mar 2005 17:37:46 +0000 (+0000) Subject: Declare annotation: support for new declare collections. X-Git-Tag: V1_5_0M2~65 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b75f15d4839cf1bce952df3d2c9361315b04032d;p=aspectj.git Declare annotation: support for new declare collections. --- diff --git a/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java b/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java index e02b8a214..5787f39c6 100644 --- a/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java +++ b/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java @@ -53,6 +53,10 @@ public class CrosscuttingMembers { private List declareSofts = new ArrayList(0); private List declareDominates = new ArrayList(4); + // These are like declare parents type mungers + private List declareAnnotationsOnType = new ArrayList(); + private List declareAnnotationsOnField = new ArrayList(); + private List declareAnnotationsOnMethods = new ArrayList(); // includes ctors public CrosscuttingMembers(ResolvedTypeX inAspect) { this.inAspect = inAspect; @@ -116,7 +120,16 @@ public class CrosscuttingMembers { declareSofts.add(new DeclareSoft(d.getException(), concretePointcut)); addConcreteShadowMunger(m); } else if (declare instanceof DeclareAnnotation) { - System.err.println("Need to implement CrosscuttingMembers.addDeclare for annotations"); + // FIXME asc perf Possible Improvement. Investigate why this is called twice in a weave ? + DeclareAnnotation da = (DeclareAnnotation)declare; + da.setAspect(this.inAspect); + if (da.isDeclareAtType()) { + declareAnnotationsOnType.add(da); + } else if (da.isDeclareAtField()) { + declareAnnotationsOnField.add(da); + } else if (da.isDeclareAtMethod() || da.isDeclareAtConstuctor()) { + declareAnnotationsOnMethods.add(da); + } } else { throw new RuntimeException("unimplemented"); } @@ -199,6 +212,22 @@ public class CrosscuttingMembers { declareSofts = other.declareSofts; } + // DECAT for when attempting to replace an aspect + if (!declareAnnotationsOnType.equals(other.declareAnnotationsOnType)) { + changed = true; + declareAnnotationsOnType = other.declareAnnotationsOnType; + } + + if (!declareAnnotationsOnField.equals(other.declareAnnotationsOnField)) { + changed = true; + declareAnnotationsOnField = other.declareAnnotationsOnField; + } + + if (!declareAnnotationsOnMethods.equals(other.declareAnnotationsOnMethods)) { + changed = true; + declareAnnotationsOnMethods = other.declareAnnotationsOnMethods; + } + return changed; } @@ -229,5 +258,20 @@ public class CrosscuttingMembers { public List getTypeMungers() { return typeMungers; } + + public List getDeclareAnnotationOnTypes() { + return declareAnnotationsOnType; + } + + public List getDeclareAnnotationOnFields() { + return declareAnnotationsOnField; + } + + /** + * includes declare @method and @constructor + */ + public List getDeclareAnnotationOnMethods() { + return declareAnnotationsOnMethods; + } } diff --git a/weaver/src/org/aspectj/weaver/CrosscuttingMembersSet.java b/weaver/src/org/aspectj/weaver/CrosscuttingMembersSet.java index f8db5c29a..44f050d11 100644 --- a/weaver/src/org/aspectj/weaver/CrosscuttingMembersSet.java +++ b/weaver/src/org/aspectj/weaver/CrosscuttingMembersSet.java @@ -37,6 +37,9 @@ public class CrosscuttingMembersSet { private List typeMungers = null; private List declareSofts = null; private List declareParents = null; + private List declareAnnotationOnTypes = null; + private List declareAnnotationOnFields = null; + private List declareAnnotationOnMethods= null; // includes ctors private List declareDominates = null; public CrosscuttingMembersSet(World world) { @@ -138,6 +141,43 @@ public class CrosscuttingMembersSet { return declareParents; } + // DECAT Merge multiple together + public List getDeclareAnnotationOnTypes() { + if (declareAnnotationOnTypes == null) { + ArrayList ret = new ArrayList(); + for (Iterator i = members.values().iterator(); i.hasNext(); ) { + ret.addAll(((CrosscuttingMembers)i.next()).getDeclareAnnotationOnTypes()); + } + declareAnnotationOnTypes = ret; + } + return declareAnnotationOnTypes; + } + + public List getDeclareAnnotationOnFields() { + if (declareAnnotationOnFields == null) { + ArrayList ret = new ArrayList(); + for (Iterator i = members.values().iterator(); i.hasNext(); ) { + ret.addAll(((CrosscuttingMembers)i.next()).getDeclareAnnotationOnFields()); + } + declareAnnotationOnFields = ret; + } + return declareAnnotationOnFields; + } + + /** + * Return an amalgamation of the declare @method/@constructor statements. + */ + public List getDeclareAnnotationOnMethods() { + if (declareAnnotationOnMethods == null) { + ArrayList ret = new ArrayList(); + for (Iterator i = members.values().iterator(); i.hasNext(); ) { + ret.addAll(((CrosscuttingMembers)i.next()).getDeclareAnnotationOnMethods()); + } + declareAnnotationOnMethods = ret; + } + return declareAnnotationOnMethods; + } + public List getDeclareDominates() { if (declareDominates == null) { ArrayList ret = new ArrayList(); diff --git a/weaver/src/org/aspectj/weaver/World.java b/weaver/src/org/aspectj/weaver/World.java index 228eeb3f1..a21414538 100644 --- a/weaver/src/org/aspectj/weaver/World.java +++ b/weaver/src/org/aspectj/weaver/World.java @@ -400,6 +400,18 @@ public abstract class World implements Dump.INode { public List getDeclareParents() { return crosscuttingMembersSet.getDeclareParents(); } + + public List getDeclareAnnotationOnTypes() { + return crosscuttingMembersSet.getDeclareAnnotationOnTypes(); + } + + public List getDeclareAnnotationOnFields() { + return crosscuttingMembersSet.getDeclareAnnotationOnFields(); + } + + public List getDeclareAnnotationOnMethods() { + return crosscuttingMembersSet.getDeclareAnnotationOnMethods(); + } public List getDeclareSoft() { return crosscuttingMembersSet.getDeclareSofts();