The API of Annotation instances. The main source of information about annotations is the scala.reflect.api.Annotations page.
An extractor class to create and pattern match with syntax Annotation(tpe, scalaArgs, javaArgs). Here, tpe is the annotation type, scalaArgs the payload of Scala annotations, and javaArgs the payload of Java annotations.
© 2002-2019 EPFL, with contributions from Lightbend.
Licensed under the Apache License, Version 2.0.
https://www.scala-lang.org/api/2.13.0/scala-reflect/scala/reflect/api/Annotations.html
EXPERIMENTAL
This trait provides annotation support for the reflection API.
In Scala, annotations belong to one of the two categories:
When a Scala annotation that inherits from scala.annotation.StaticAnnotation is compiled, it is stored as special attributes in the corresponding classfile, and not as a Java annotation. Note that subclassing just scala.annotation.Annotation is not enough to have the corresponding metadata persisted for runtime reflection.
Both Java and Scala annotations are represented as typed trees carrying constructor invocations corresponding to the annotation. For instance, the annotation in
@ann(1, 2) class Cis represented asq"@new ann(1, 2)".Unlike Java reflection, Scala reflection does not support evaluation of constructor invocations stored in annotations into underlying objects. For instance it's impossible to go from
@ann(1, 2) class Ctoann(1, 2), so one has to analyze trees representing annotation arguments to manually extract corresponding values. Towards that end, arguments of an annotation can be obtained viaannotation.tree.children.tail.For more information about
Annotations, see the Reflection Guide: Annotations, Names, Scopes, and More