// 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
// 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;
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.
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) {
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;
}
}
+ 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) {
}
}
+ 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++) {