Java meta annotations

Source: Internet
Author: User

The role of the Java Meta annotation is to annotate other annotations, java5.0 defines four standard meta-annotations: @Target, @Retention, @Inherit, @Documented.

1) @Target: Used to describe the types of annotations that can be decorated. The optional values are: (Elementtype.type)

Annotation_type (annotation type declaration)

Package (packages)

Type (class, interface, enumeration)

Methods (method declaration)

FIELD (member variable)

local_variable (local variable)

CONSTRUCTOR (Construction method)

The code is as follows:

@Documented @retention (retentionpolicy.runtime) @Target (elementtype.annotation_type)  public @Interface  target{   elementtype[] Value ();   }

2) @Retention Note: Used to mark the action phase of the annotation, the following values are desirable: (Retentionpolicy.runtime)

Source: Works in the code, the compilation phase is removed;

Class: Can be compiled into a class file, but the JVM ignores it;

RUNTIME:JVM is used at run time.

    

3) Documented note: Used to indicate that this annotation should be recorded by the Javadoc tool

4) Inherit Annotations: Annotations that indicate that a subclass can inherit from a parent class.

    

    

Java meta annotations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.