Scala: annotation and scala Annotation

Source: Internet
Author: User

Scala: annotation and scala Annotation
Annotations can be used to add information to various entries of a program. They are inserted into the code so that tools can process tags for them. You can use java annotations for scala classes or scala-specific annotations.

In scala, annotations can be added for classes, methods, fields, local variables, and parameters. Java annotation parameter types can only be:
1) numeric Variables
2) String
3) class variables
4) java Enumeration
5) other annotations
6) arrays of the above types.

To implement a new Java annotation, you must use Java to compile the annotation class. Scala uses @ clonable and @ remote to mark cloned and remote objects. @ Varargs annotation can call Scala's method with variable length parameters from Java.

Some annotations in the Scala class library can control Compiler Optimization. @ tailrec is used to eliminate recursion. The @ switch annotation can check whether scala's match statement is actually compiled into a jump table, we recommend that the compiler use @ inline to inline and @ editable to mark the methods that can be removed from the production code. The Compiler replaces the omitted method with the Unit object, @ uncheckVariance: the error message related to the type change is canceled.

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.