Can someone describe the use of annotation processing?
My last attempt to understand annotations was unsuccessful.
Previously I posted this question but couldn’t get a satisfactory answer.
I went through many online tutorials but most of them are about annotations used for:
- Documentation
- Annotations used by the compiler (
@Deprecated,@Override,@SuppressWarnings) - Annotation processing (
@Targetand@Retention)
Please someone explain me Annotation Processing by directing me to appropriate tutorial.
To be very precise I want to know more about the following
Meta-Annotations (Java Annotation Types):
- Target
- Retention
- Documented
- Inherited
I already went through many tutorials like this but couldn’t get much information on Annotation Processing.
The annotations asked about are annotations used for annotating Annotations. Their specific purposes are:
Target: Specifies where you can use the annotation. E.g.@Target(ElementType.METHOD)means the Annotation can only be used on methods.Retention: Specifies where/when the annotation is available.@Retention(RetentionPolicy.RUNTIME)means it is available at runtime using reflection. Other values make it only in the class files orat compile time (the options mentioned first include the later options)DocumentedAn annotation with this annotation will apear in javadocInheritedmakes subclasses inherit the annoteted annotation from their superclassesFor all four the javadoc is quite helpfull.