mardi 5 février 2019

Attempt to create proxy for a non-annotation type

Why do I get java.lang.annotation.AnnotationFormatError: Attempt to create proxy for a non-annotation type. when I'm trying to get the annotation list from the field?

My annotation:

@Target({ ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
private @interface TypicalAnnotation
{
    int size();
}

Usage:

public static class MockAnnotatedClass
{
    @TypicalAnnotation(size = 3)
    public Integer number = 2;
}

Call:

ReflectionUtils.getAllFields(clazz1).getAnnotations() <- got the exception.





Aucun commentaire:

Enregistrer un commentaire