I am unable to retrieve the annotation at the left of the square brackets of an array:
public static @MyNullable1 String @MyNullable2[] array = null;
@Test
public void test() throws Exception {
Annotation[] annotations = getClass().getField("array").getAnnotations();
System.out.println(Arrays.toString(annotations));
}
The result is only:
[@test.MyNullable1()]
And, if I remove the @MyNullable2, IDEA reports 'null' is assigned to a variable that is annotated with @NotNull:

Why is IDEA reporting this? How can I get the annotation at the left of the square brackets? And what's different in annotations at different positions?
Here are MyNullable1 and MyNullable2:
@Documented
@Nonnull(when = When.MAYBE)
@Retention(RetentionPolicy.RUNTIME)
@TypeQualifierNickname
@Target({
ElementType.METHOD,
ElementType.FIELD,
ElementType.PARAMETER,
ElementType.LOCAL_VARIABLE,
ElementType.TYPE_USE,
})
public @interface MyNullable1 {}
@Documented
@Nonnull(when = When.MAYBE)
@Retention(RetentionPolicy.RUNTIME)
@TypeQualifierNickname
@Target({
ElementType.METHOD,
ElementType.FIELD,
ElementType.PARAMETER,
ElementType.LOCAL_VARIABLE,
ElementType.TYPE_USE,
})
public @interface MyNullable2 {}