What are the exact default values of two meta annotations (Target and Retention) in a user defined annotation?
public @interface AnnotationWithDefaultProps { }
Advertisement
Answer
According to the source code, none of them has a default value, which means you must provide it, whenever you use the annotation. The meaning of the missing annotation is defined in the javadoc:
For Target
it means
If a Target meta-annotation is not present on an annotation type declaration, the declared type may be used on any program element.
and for Retention
it means
If no Retention annotation is present on an annotation type declaration, the retention policy defaults to RetentionPolicy.CLASS.