final int INVISIBLE_INDEX = 1;
int invisibleParametersAnnotationsCounter = 0;
int visibleParametersAnnotationsCounter = 0;
int[][] annotationsCounters = new int[argumentsLength][2];
for (int i = 0; i < argumentsLength; i++) {
Argument argument = arguments[i];
Annotation[] annotations = argument.annotations;
if (annotations != null) {
for (int j = 0, max2 = annotations.length; j < max2; j++) {
Annotation annotation;
if ((annotation = annotations[j].getPersistibleAnnotation()) == null) continue; // already packaged into container.
long annotationMask = annotation.resolvedType != null ? annotation.resolvedType.getAnnotationTagBits() & TagBits.AnnotationTargetMASK : 0;
if (annotationMask != 0 && (annotationMask & TagBits.AnnotationForParameter) == 0) continue;
if (annotation.isRuntimeInvisible()) {
annotationsCounters[i][INVISIBLE_INDEX]++;
invisibleParametersAnnotationsCounter++;
} else if (annotation.isRuntimeVisible()) {
annotationsCounters[i][VISIBLE_INDEX]++;
visibleParametersAnnotationsCounter++;
}
}
}
}
int attributesNumber = 0;
int annotationAttributeOffset = this.contentsOffset;
if (invisibleParametersAnnotationsCounter != 0) {
int globalCounter = 0;
if (this.contentsOffset + 7 >= this.contents.length) {
resizeContents(7);
}
int attributeNameIndex =
this.constantPool.literalIndex(AttributeNamesConstants.RuntimeInvisibleParameterAnnotationsName);
this.contents[this.contentsOffset++] = (byte) (attributeNameIndex >> 8);
this.contents[this.contentsOffset++] = (byte) attributeNameIndex;
int attributeLengthOffset = this.contentsOffset;
this.contentsOffset += 4; // leave space for the attribute length
this.contents[this.contentsOffset++] = (byte) argumentsLength;
for (int i = 0; i < argumentsLength; i++) {
if (this.contentsOffset + 2 >= this.contents.length) {
resizeContents(2);
}
if (invisibleParametersAnnotationsCounter == 0) {
this.contents[this.contentsOffset++] = (byte) 0;
this.contents[this.contentsOffset++] = (byte) 0;
} else {
final int numberOfInvisibleAnnotations = annotationsCounters[i][INVISIBLE_INDEX];
int invisibleAnnotationsOffset = this.contentsOffset;
// leave space for number of annotations
this.contentsOffset += 2;
int counter = 0;
if (numberOfInvisibleAnnotations != 0) {
Argument argument = arguments[i];
Annotation[] annotations = argument.annotations;
for (int j = 0, max = annotations.length; j < max; j++) {
Annotation annotation;
if ((annotation = annotations[j].getPersistibleAnnotation()) == null) continue; // already packaged into container.
long annotationMask = annotation.resolvedType != null ? annotation.resolvedType.getAnnotationTagBits() & TagBits.AnnotationTargetMASK : 0;
if (annotationMask != 0 && (annotationMask & TagBits.AnnotationForParameter) == 0) continue;
if (annotation.isRuntimeInvisible()) {
int currentAnnotationOffset = this.contentsOffset;
generateAnnotation(annotation, currentAnnotationOffset);
if (this.contentsOffset != currentAnnotationOffset) {
counter++;
globalCounter++;
}
invisibleParametersAnnotationsCounter--;
}
}
}
this.contents[invisibleAnnotationsOffset++] = (byte) (counter >> 8);
this.contents[invisibleAnnotationsOffset] = (byte) counter;
}
}
if (globalCounter != 0) {
int attributeLength = this.contentsOffset - attributeLengthOffset - 4;
this.contents[attributeLengthOffset++] = (byte) (attributeLength >> 24);
this.contents[attributeLengthOffset++] = (byte) (attributeLength >> 16);
this.contents[attributeLengthOffset++] = (byte) (attributeLength >> 8);
this.contents[attributeLengthOffset++] = (byte) attributeLength;
attributesNumber++;
} else {
// if globalCounter is 0, this means that the code generation for all visible annotations failed
this.contentsOffset = annotationAttributeOffset;
}
}
if (visibleParametersAnnotationsCounter != 0) {
int globalCounter = 0;
if (this.contentsOffset + 7 >= this.contents.length) {
resizeContents(7);
}
int attributeNameIndex =
this.constantPool.literalIndex(AttributeNamesConstants.RuntimeVisibleParameterAnnotationsName);
this.contents[this.contentsOffset++] = (byte) (attributeNameIndex >> 8);
this.contents[this.contentsOffset++] = (byte) attributeNameIndex;
int attributeLengthOffset = this.contentsOffset;
this.contentsOffset += 4; // leave space for the attribute length
this.contents[this.contentsOffset++] = (byte) argumentsLength;
for (int i = 0; i < argumentsLength; i++) {
if (this.contentsOffset + 2 >= this.contents.length) {
resizeContents(2);
}
if (visibleParametersAnnotationsCounter == 0) {
this.contents[this.contentsOffset++] = (byte) 0;
this.contents[this.contentsOffset++] = (byte) 0;
} else {
final int numberOfVisibleAnnotations = annotationsCounters[i][VISIBLE_INDEX];
int visibleAnnotationsOffset = this.contentsOffset;
// leave space for number of annotations
this.contentsOffset += 2;
int counter = 0;
if (numberOfVisibleAnnotations != 0) {
Argument argument = arguments[i];
Annotation[] annotations = argument.annotations;
for (int j = 0, max = annotations.length; j < max; j++) {
Annotation annotation;
if ((annotation = annotations[j].getPersistibleAnnotation()) == null) continue; // already packaged into container.
long annotationMask = annotation.resolvedType != null ? annotation.resolvedType.getAnnotationTagBits() & TagBits.AnnotationTargetMASK : 0;