aboutsummaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelMethod.java24
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java32
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java40
3 files changed, 94 insertions, 2 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java b/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java
index adb91f8d9..06c02fb37 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java
@@ -374,6 +374,30 @@ class BcelMethod extends ResolvedMemberImpl {
// method.addAnnotation(annotation.getBcelAnnotation());
}
+ public static final AnnotationAJ[] NO_PARAMETER_ANNOTATIONS = new AnnotationAJ[] {};
+
+ public void addParameterAnnotation(int param, AnnotationAJ anno) {
+ ensureParameterAnnotationsRetrieved();
+ if (parameterAnnotations == NO_PARAMETER_ANNOTATIONXS) {
+ // First time we've added any, so lets set up the array
+ parameterAnnotations = new AnnotationAJ[getArity()][];
+ for (int i = 0; i < getArity(); i++) {
+ parameterAnnotations[i] = NO_PARAMETER_ANNOTATIONS;
+ }
+ }
+ int existingCount = parameterAnnotations[param].length;
+ if (existingCount == 0) {
+ AnnotationAJ[] annoArray = new AnnotationAJ[1];
+ annoArray[0] = anno;
+ parameterAnnotations[param] = annoArray;
+ } else {
+ AnnotationAJ[] newAnnoArray = new AnnotationAJ[existingCount + 1];
+ System.arraycopy(parameterAnnotations[param], 0, newAnnoArray, 0, existingCount);
+ newAnnoArray[existingCount] = anno;
+ parameterAnnotations[param] = newAnnoArray;
+ }
+ }
+
private void ensureAnnotationsRetrieved() {
if (method == null)
return; // must be ok, we have evicted it
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
index 7947d526c..b3f1e9fb2 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
@@ -786,8 +786,7 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
// pr98901
// For copying the annotations across, we have to discover the real
- // member in the aspect
- // which is holding them.
+ // member in the aspect which is holding them.
if (weaver.getWorld().isInJava5Mode()) {
AnnotationAJ annotationsOnRealMember[] = null;
ResolvedType toLookOn = aspectType;
@@ -807,6 +806,20 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
newMethod.addAnnotation(new BcelAnnotation(ag, weaver.getWorld()));
}
}
+ AnnotationAJ[][] pAnnos = realMember.getParameterAnnotations();
+ int offset = newMethod.isStatic() ? 0 : 1;
+ if (pAnnos != null && pAnnos.length != 0) {
+ int param = 0;
+ for (int i = offset; i < pAnnos.length; i++) {
+ AnnotationAJ[] annosOnParam = pAnnos[i];
+ if (annosOnParam != null && annosOnParam.length > 0) {
+ for (int j = 0; j < annosOnParam.length; j++) {
+ newMethod.addParameterAnnotation(param, annosOnParam[j]);
+ }
+ }
+ param++;
+ }
+ }
// the below loop fixes the very special (and very stupid)
// case where an aspect declares an annotation
// on an ITD it declared on itself.
@@ -914,6 +927,21 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
mg.addAnnotation(new BcelAnnotation(ag, weaver.getWorld()));
}
}
+
+ AnnotationAJ[][] pAnnos = realMember.getParameterAnnotations();
+ int offset = mg.isStatic() ? 0 : 1;
+ if (pAnnos != null && pAnnos.length != 0) {
+ int param = 0;
+ for (int i = offset; i < pAnnos.length; i++) {
+ AnnotationAJ[] annosOnParam = pAnnos[i];
+ if (annosOnParam != null && annosOnParam.length > 0) {
+ for (int j = 0; j < annosOnParam.length; j++) {
+ mg.addParameterAnnotation(param, annosOnParam[j]);
+ }
+ }
+ param++;
+ }
+ }
}
if (mungingInterface) {
diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
index 57e1286e1..7397ddb0a 100644
--- a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
+++ b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
@@ -89,6 +89,7 @@ public final class LazyMethodGen implements Traceable {
private InstructionList body; // leaving null for abstracts
private List attributes;
private List newAnnotations;
+ private AnnotationAJ[][] newParameterAnnotations;
private final LazyClassGen enclosingClass;
private BcelMethod memberView;
private AjAttribute.EffectiveSignatureAttribute effectiveSignature;
@@ -276,6 +277,35 @@ public final class LazyMethodGen implements Traceable {
}
}
+ private static final AnnotationAJ[] NO_ANNOTATIONAJ = new AnnotationAJ[] {};
+
+ public void addParameterAnnotation(int parameterNumber, AnnotationAJ anno) {
+ initialize();
+ if (memberView == null) {
+ if (newParameterAnnotations == null) {
+ // time to create it
+ int pcount = getArgumentTypes().length;
+ newParameterAnnotations = new AnnotationAJ[pcount][];
+ for (int i = 0; i < pcount; i++) {
+ if (i == parameterNumber) {
+ newParameterAnnotations[i] = new AnnotationAJ[1];
+ newParameterAnnotations[i][0] = anno;
+ } else {
+ newParameterAnnotations[i] = NO_ANNOTATIONAJ;
+ }
+ }
+ } else {
+ AnnotationAJ[] currentAnnoArray = newParameterAnnotations[parameterNumber];
+ AnnotationAJ[] newAnnoArray = new AnnotationAJ[currentAnnoArray.length + 1];
+ System.arraycopy(currentAnnoArray, 0, newAnnoArray, 0, currentAnnoArray.length);
+ newAnnoArray[currentAnnoArray.length] = anno;
+ newParameterAnnotations[parameterNumber] = newAnnoArray;
+ }
+ } else {
+ memberView.addParameterAnnotation(parameterNumber, anno);
+ }
+ }
+
public boolean hasAnnotation(UnresolvedType annotationTypeX) {
initialize();
if (memberView == null) {
@@ -898,6 +928,16 @@ public final class LazyMethodGen implements Traceable {
}
}
+ if (newParameterAnnotations != null) {
+ for (int i = 0; i < newParameterAnnotations.length; i++) {
+ AnnotationAJ[] annos = newParameterAnnotations[i];
+ for (int j = 0; j < annos.length; j++) {
+ gen.addParameterAnnotation(i, new AnnotationGen(((BcelAnnotation) annos[j]).getBcelAnnotation(), gen
+ .getConstantPool(), true));
+ }
+ }
+ }
+
if (memberView != null && memberView.getAnnotations() != null && memberView.getAnnotations().length != 0) {
AnnotationAJ[] ans = memberView.getAnnotations();
for (int i = 0, len = ans.length; i < len; i++) {