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.
Scala Overview: Annotation