Annotation annot = sourceAnnotations[j];
/*
* Annotations are shared between two locals, but we still need to record
* the suppress annotation range for the second local
*/
AnnotationBinding annotationBinding = annot.getCompilerAnnotation();
annotations[j] = annotationBinding;
if (annotationBinding != null) {
final ReferenceBinding annotationType = annotationBinding.getAnnotationType();
if (annotationType != null && annotationType.id == TypeIds.T_JavaLangSuppressWarnings) {
annot.recordSuppressWarnings(scope, declarationSourceStart, declarationSourceEnd, scope.compilerOptions().suppressWarnings);
}
}
}
}
break;
}
return annotations;
} else {
annotation.recipient = recipient;
annotation.resolveType(scope);
// null if receiver is a package binding
if (annotations != null) {
annotations[i] = annotation.getCompilerAnnotation();
}
}
}
/* See if the recipient is meta-annotated with @Repeatable and if so validate constraints. We can't do this during resolution of @Repeatable itself as @Target and
@Retention etc could come later
*/
if (recipient != null && recipient.isTaggedRepeatable()) {
for (int i = 0; i < length; i++) {
Annotation annotation = sourceAnnotations[i];
ReferenceBinding annotationType = annotations[i] != null ? annotations[i].getAnnotationType() : null;
if (annotationType != null && annotationType.id == TypeIds.T_JavaLangAnnotationRepeatable)
annotation.checkRepeatableMetaAnnotation(scope);
}
}
// check duplicate annotations
if (annotations != null && length > 1) {
AnnotationBinding[] distinctAnnotations = annotations; // only copy after 1st duplicate is detected
Map implicitContainerAnnotations = null;
for (int i = 0; i < length; i++) {
AnnotationBinding annotation = distinctAnnotations[i];
if (annotation == null) continue;
ReferenceBinding annotationType = annotation.getAnnotationType();
boolean foundDuplicate = false;
ContainerAnnotation container = null;
for (int j = i+1; j < length; j++) {
AnnotationBinding otherAnnotation = distinctAnnotations[j];
if (otherAnnotation == null) continue;
if (TypeBinding.equalsEquals(otherAnnotation.getAnnotationType(), annotationType)) {
if (distinctAnnotations == annotations) {
System.arraycopy(distinctAnnotations, 0, distinctAnnotations = new AnnotationBinding[length], 0, length);
}
distinctAnnotations[j] = null; // report/process it only once
if (annotationType.isRepeatableAnnotationType()) {