![]() ![]() ElementType.TYPE_USE can be applied to a use of type (Since Java 8).ElementType.TYPE_PARAMETER can be applied to a type parameter (Since Java 8).ElementType.TYPE can be applied to a type (class, interface, enum or annotation).ElementType.PARAMETER can be applied to a method parameter.ElementType.PACKAGE can be applied to a package (placed in package-info.java file).ElementType.METHOD can be applied to a method.ElementType.LOCAL_VARIABLE can be applied to a local variable.ElementType.FIELD can be applied to a field (includes enum constants).ElementType.CONSTRUCTOR can be applied to a constructor.ElementType.ANNOTATION_TYPE can be applied to an annotation type (creates meta-annotation).Specifies one or more of the following element types as its value: The annotation in the generated Java annotation marksĪnother annotation to restrict what kind of Java elements the annotation can be applied to. We can see that only getName() method, which is annotated with has Let’s define an annotation annotated with RetentionPolicy.SOURCE This can be used when you use reflection. RetentionPolicy.RUNTIME – The marked annotation is retained by the JVM so it can be used by the runtimeĮnvironment.It might be useful if you want to do byte code-level post-processing. I don’t know what is the useĬase for this type. Thus it is in class file but not retained by JVM at runtime. ![]() ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |