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.