aboutsummaryrefslogtreecommitdiffstats
path: root/weaver/src
diff options
context:
space:
mode:
authorAndy Clement <andrew.clement@gmail.com>2013-06-13 12:29:45 -0700
committerAndy Clement <andrew.clement@gmail.com>2013-06-13 12:29:45 -0700
commit5b0b6b07d2b581cddd1bac4a2a6b12cd4ac02b07 (patch)
treed70190d982a521f6392c71946c7a92e466e81b93 /weaver/src
parent31d8e259e5cd8b1b4810d69bbf4b9ea45ae4a4c8 (diff)
downloadaspectj-5b0b6b07d2b581cddd1bac4a2a6b12cd4ac02b07.tar.gz
aspectj-5b0b6b07d2b581cddd1bac4a2a6b12cd4ac02b07.zip
Preserve ordering of declare annotation when removing and adding annotations
Issue: 407739
Diffstat (limited to 'weaver/src')
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
index b1534ca73..fbb4d9292 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
@@ -1264,6 +1264,26 @@ class BcelClassWeaver implements IClassWeaver {
return false;
}
+ /**
+ * Remove an annotation from the supplied array, if it is in there.
+ */
+ private AnnotationAJ[] removeFromAnnotationsArray(AnnotationAJ[] annotations,AnnotationAJ annotation) {
+ for (int i=0;i<annotations.length;i++) {
+ if (annotations[i] != null && annotation.getTypeName().equals(annotations[i].getTypeName())) {
+ // Remove it!
+ AnnotationAJ[] newArray = new AnnotationAJ[annotations.length-1];
+ int index=0;
+ for (int j=0;j<annotations.length;j++) {
+ if (j!=i) {
+ newArray[index++]=annotations[j];
+ }
+ }
+ return newArray;
+ }
+ }
+ return annotations;
+ }
+
// BUGWARNING not getting enough warnings out on declare @field ? There is a potential problem here with warnings not
// coming out - this will occur if they are created on the second iteration round this loop.
// We currently deactivate error reporting for the second time round. A possible solution is to record what annotations
@@ -1320,6 +1340,7 @@ class BcelClassWeaver implements IClassWeaver {
AsmRelationshipProvider.addDeclareAnnotationFieldRelationship(world.getModelAsAsmManager(),
decaf.getSourceLocation(), clazz.getName(), field, true);
reportFieldAnnotationWeavingMessage(clazz, field, decaf, true);
+ dontAddMeTwice = removeFromAnnotationsArray(dontAddMeTwice, annotation);
} else {
worthRetrying.add(decaf);
}