trait Annotations extends AnyRef
EXPERIMENTAL
This trait provides annotation support for the reflection API.
In Scala, annotations belong to one of the two categories:
- Java annotations: annotations on definitions produced by the Java compiler, i.e., subtypes of java.lang.annotation.Annotation attached to program definitions. When read by Scala reflection, the scala.annotation.ClassfileAnnotation trait is automatically added as a subclass to every Java annotation.
- Scala annotations: annotations on definitions or types produced by the Scala compiler.
When a Scala annotation that inherits from scala.annotation.StaticAnnotation or scala.annotation.ClassfileAnnotation 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 C is represented as q"@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 C to ann(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 via annotation.tree.children.tail.
 For more information about Annotations, see the Reflection Guide: Annotations, Names, Scopes, and More
- Self Type
- Universe
- Source
- Annotations.scala
- Grouped
- Alphabetic
- By Inheritance
- Annotations
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Type Members
- 
      
      
      
        
      
    
      
        abstract 
        type
      
      
        
              Annotation
             >: Null <: Universe.AnnotationApi
      
      
      Information about an annotation. 
- 
      
      
      
        
      
    
      
        
        trait
      
      
        
              AnnotationApi
             extends AnyRef
      
      
      The API of Annotationinstances.The API of Annotationinstances. The main source of information about annotations is the scala.reflect.api.Annotations page.
- 
      
      
      
        
      
    
      
        abstract 
        class
      
      
        
              AnnotationExtractor
             extends AnyRef
      
      
      An extractor class to create and pattern match with syntax Annotation(tpe, scalaArgs, javaArgs).An extractor class to create and pattern match with syntax Annotation(tpe, scalaArgs, javaArgs). Here,tpeis the annotation type,scalaArgsthe payload of Scala annotations, andjavaArgsthe payload of Java annotations.
- 
      
      
      
        
      
    
      
        abstract 
        type
      
      
        
              ArrayArgument
             >: Null <: Universe.ArrayArgumentApi with Universe.JavaArgument
      
      
      An array argument to a Java annotation as in @Target(value={TYPE,FIELD,METHOD,PARAMETER})An array argument to a Java annotation as in @Target(value={TYPE,FIELD,METHOD,PARAMETER})- Annotations
- @deprecated
- Deprecated
- (Since version 2.11.0) Use - Annotation.treeto inspect annotation arguments
 
- 
      
      
      
        
      
    
      
        
        trait
      
      
        
              ArrayArgumentApi
             extends AnyRef
      
      
      API of ArrayArgumentinstances.API of ArrayArgumentinstances. The main source of information about annotations is the scala.reflect.api.Annotations page.- Annotations
- @deprecated
- Deprecated
- (Since version 2.11.0) Use - Annotation.treeto inspect annotation arguments
 
- 
      
      
      
        
      
    
      
        abstract 
        class
      
      
        
              ArrayArgumentExtractor
             extends AnyRef
      
      
      An extractor class to create and pattern match with syntax ArrayArgument(args)whereargsis the argument array.An extractor class to create and pattern match with syntax ArrayArgument(args)whereargsis the argument array.- Annotations
- @deprecated
- Deprecated
- (Since version 2.11.0) Use - Annotation.treeto inspect annotation arguments
 
- 
      
      
      
        
      
    
      
        abstract 
        type
      
      
        
              JavaArgument
             >: Null <: Universe.JavaArgumentApi
      
      
      A Java annotation argument A Java annotation argument - Annotations
- @deprecated
- Deprecated
- (Since version 2.11.0) Use - Annotation.treeto inspect annotation arguments
 
- 
      
      
      
        
      
    
      
        
        trait
      
      
        
              JavaArgumentApi
             extends AnyRef
      
      
      Has no special methods. Has no special methods. Is here to provides erased identity for CompoundType.- Annotations
- @deprecated
- Deprecated
- (Since version 2.11.0) Use - Annotation.treeto inspect annotation arguments
 
- 
      
      
      
        
      
    
      
        abstract 
        type
      
      
        
              LiteralArgument
             >: Null <: Universe.LiteralArgumentApi with Universe.JavaArgument
      
      
      A literal argument to a Java annotation as "Use X instead"in@Deprecated("Use X instead")A literal argument to a Java annotation as "Use X instead"in@Deprecated("Use X instead")- Annotations
- @deprecated
- Deprecated
- (Since version 2.11.0) Use - Annotation.treeto inspect annotation arguments
 
- 
      
      
      
        
      
    
      
        
        trait
      
      
        
              LiteralArgumentApi
             extends AnyRef
      
      
      The API of LiteralArgumentinstances.The API of LiteralArgumentinstances. The main source of information about annotations is the scala.reflect.api.Annotations page.- Annotations
- @deprecated
- Deprecated
- (Since version 2.11.0) Use - Annotation.treeto inspect annotation arguments
 
- 
      
      
      
        
      
    
      
        abstract 
        class
      
      
        
              LiteralArgumentExtractor
             extends AnyRef
      
      
      An extractor class to create and pattern match with syntax LiteralArgument(value)wherevalueis the constant argument.An extractor class to create and pattern match with syntax LiteralArgument(value)wherevalueis the constant argument.- Annotations
- @deprecated
- Deprecated
- (Since version 2.11.0) Use - Annotation.treeto inspect annotation arguments
 
- 
      
      
      
        
      
    
      
        abstract 
        type
      
      
        
              NestedArgument
             >: Null <: Universe.NestedArgumentApi with Universe.JavaArgument
      
      
      A nested annotation argument to a Java annotation as @Nestedin@Outer(@Nested).A nested annotation argument to a Java annotation as @Nestedin@Outer(@Nested).- Annotations
- @deprecated
- Deprecated
- (Since version 2.11.0) Use - Annotation.treeto inspect annotation arguments
 
- 
      
      
      
        
      
    
      
        
        trait
      
      
        
              NestedArgumentApi
             extends AnyRef
      
      
      API of NestedArgumentinstances.API of NestedArgumentinstances. The main source of information about annotations is the scala.reflect.api.Annotations page.- Annotations
- @deprecated
- Deprecated
- (Since version 2.11.0) Use - Annotation.treeto inspect annotation arguments
 
- 
      
      
      
        
      
    
      
        abstract 
        class
      
      
        
              NestedArgumentExtractor
             extends AnyRef
      
      
      An extractor class to create and pattern match with syntax NestedArgument(annotation)whereannotationis the nested annotation.An extractor class to create and pattern match with syntax NestedArgument(annotation)whereannotationis the nested annotation.- Annotations
- @deprecated
- Deprecated
- (Since version 2.11.0) Use - Annotation.treeto inspect annotation arguments
 
Abstract Value Members
- 
      
      
      
        
      
    
      
        abstract 
        val
      
      
        Annotation: Universe.AnnotationExtractor
      
      
      The constructor/extractor for Annotationinstances.
- 
      
      
      
        
      
    
      
        abstract 
        def
      
      
        annotationToTree(ann: Universe.Annotation): Universe.Tree
      
      
      - Attributes
- protected[scala]
 
- 
      
      
      
        
      
    
      
        abstract 
        def
      
      
        treeToAnnotation(tree: Universe.Tree): Universe.Annotation
      
      
      - Attributes
- protected[scala]
 
- 
      
      
      
        
      
    
      
        abstract 
        val
      
      
        ArrayArgument: Universe.ArrayArgumentExtractor
      
      
      The constructor/extractor for ArrayArgumentinstances.The constructor/extractor for ArrayArgumentinstances.- Annotations
- @deprecated
- Deprecated
- (Since version 2.11.0) Use - Annotation.treeto inspect annotation arguments
 
- 
      
      
      
        
      
    
      
        abstract 
        val
      
      
        LiteralArgument: Universe.LiteralArgumentExtractor
      
      
      The constructor/extractor for LiteralArgumentinstances.The constructor/extractor for LiteralArgumentinstances.- Annotations
- @deprecated
- Deprecated
- (Since version 2.11.0) Use - Annotation.treeto inspect annotation arguments
 
- 
      
      
      
        
      
    
      
        abstract 
        val
      
      
        NestedArgument: Universe.NestedArgumentExtractor
      
      
      The constructor/extractor for NestedArgumentinstances.The constructor/extractor for NestedArgumentinstances.- Annotations
- @deprecated
- Deprecated
- (Since version 2.11.0) Use - Annotation.treeto inspect annotation arguments
 
Concrete Value Members
- 
      
      
      
        
      
    
      
        final 
        def
      
      
        !=(arg0: Any): Boolean
      
      
      Test two objects for inequality. Test two objects for inequality. - returns
- trueif !(this == that), false otherwise.
 - Definition Classes
- AnyRef → Any
 
- 
      
      
      
        
      
    
      
        final 
        def
      
      
        ##(): Int
      
      
      Equivalent to x.hashCodeexcept for boxed numeric types andnull.Equivalent to x.hashCodeexcept for boxed numeric types andnull. For numerics, it returns a hash value which is consistent with value equality: if two value type instances compare as true, then ## will produce the same hash value for each of them. Fornullreturns a hashcode wherenull.hashCodethrows aNullPointerException.- returns
- a hash value consistent with == 
 - Definition Classes
- AnyRef → Any
 
- 
      
      
      
        
      
    
      
        
        def
      
      
        +(other: String): String
      
      
      - Implicit
- This member is added by an implicit conversion from Annotations to any2stringadd[Annotations] performed by method any2stringadd in scala.Predef.
- Definition Classes
- any2stringadd
 
- 
      
      
      
        
      
    
      
        
        def
      
      
        ->[B](y: B): (Annotations, B)
      
      
      - Implicit
- This member is added by an implicit conversion from Annotations to ArrowAssoc[Annotations] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @inline()
 
- 
      
      
      
        
      
    
      
        final 
        def
      
      
        ==(arg0: Any): Boolean
      
      
      The expression x == thatis equivalent toif (x eq null) that eq null else x.equals(that).The expression x == thatis equivalent toif (x eq null) that eq null else x.equals(that).- returns
- trueif the receiver object is equivalent to the argument;- falseotherwise.
 - Definition Classes
- AnyRef → Any
 
- 
      
      
      
        
      
    
      
        final 
        def
      
      
        asInstanceOf[T0]: T0
      
      
      Cast the receiver object to be of type T0.Cast the receiver object to be of type T0.Note that the success of a cast at runtime is modulo Scala's erasure semantics. Therefore the expression 1.asInstanceOf[String]will throw aClassCastExceptionat runtime, while the expressionList(1).asInstanceOf[List[String]]will not. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the requested type.- returns
- the receiver object. 
 - Definition Classes
- Any
- Exceptions thrown
- ClassCastExceptionif the receiver object is not an instance of the erasure of type- T0.
 
- 
      
      
      
        
      
    
      
        
        def
      
      
        clone(): AnyRef
      
      
      Create a copy of the receiver object. Create a copy of the receiver object. The default implementation of the clonemethod is platform dependent.- returns
- a copy of the receiver object. 
 - Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
- Note
- not specified by SLS as a member of AnyRef 
 
- 
      
      
      
        
      
    
      
        
        def
      
      
        ensuring(cond: (Annotations) ⇒ Boolean, msg: ⇒ Any): Annotations
      
      
      - Implicit
- This member is added by an implicit conversion from Annotations to Ensuring[Annotations] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
 
- 
      
      
      
        
      
    
      
        
        def
      
      
        ensuring(cond: (Annotations) ⇒ Boolean): Annotations
      
      
      - Implicit
- This member is added by an implicit conversion from Annotations to Ensuring[Annotations] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
 
- 
      
      
      
        
      
    
      
        
        def
      
      
        ensuring(cond: Boolean, msg: ⇒ Any): Annotations
      
      
      - Implicit
- This member is added by an implicit conversion from Annotations to Ensuring[Annotations] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
 
- 
      
      
      
        
      
    
      
        
        def
      
      
        ensuring(cond: Boolean): Annotations
      
      
      - Implicit
- This member is added by an implicit conversion from Annotations to Ensuring[Annotations] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
 
- 
      
      
      
        
      
    
      
        final 
        def
      
      
        eq(arg0: AnyRef): Boolean
      
      
      Tests whether the argument ( that) is a reference to the receiver object (this).Tests whether the argument ( that) is a reference to the receiver object (this).The eqmethod implements an equivalence relation on non-null instances ofAnyRef, and has three additional properties:- It is consistent: for any non-null instances xandyof typeAnyRef, multiple invocations ofx.eq(y)consistently returnstrueor consistently returnsfalse.
- For any non-null instance xof typeAnyRef,x.eq(null)andnull.eq(x)returnsfalse.
- null.eq(null)returns- true.
 When overriding the equalsorhashCodemethods, it is important to ensure that their behavior is consistent with reference equality. Therefore, if two objects are references to each other (o1 eq o2), they should be equal to each other (o1 == o2) and they should hash to the same value (o1.hashCode == o2.hashCode).- returns
- trueif the argument is a reference to the receiver object;- falseotherwise.
 - Definition Classes
- AnyRef
 
- It is consistent: for any non-null instances 
- 
      
      
      
        
      
    
      
        
        def
      
      
        equals(arg0: Any): Boolean
      
      
      The equality method for reference types. 
- 
      
      
      
        
      
    
      
        
        def
      
      
        finalize(): Unit
      
      
      Called by the garbage collector on the receiver object when there are no more references to the object. Called by the garbage collector on the receiver object when there are no more references to the object. The details of when and if the finalizemethod is invoked, as well as the interaction betweenfinalizeand non-local returns and exceptions, are all platform dependent.- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
- Note
- not specified by SLS as a member of AnyRef 
 
- 
      
      
      
        
      
    
      
        
        def
      
      
        formatted(fmtstr: String): String
      
      
      - Implicit
- This member is added by an implicit conversion from Annotations to StringFormat[Annotations] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @inline()
 
- 
      
      
      
        
      
    
      
        final 
        def
      
      
        getClass(): Class[_]
      
      
      Returns the runtime class representation of the object. Returns the runtime class representation of the object. - returns
- a class object corresponding to the runtime type of the receiver. 
 - Definition Classes
- AnyRef → Any
 
- 
      
      
      
        
      
    
      
        
        def
      
      
        hashCode(): Int
      
      
      The hashCode method for reference types. 
- 
      
      
      
        
      
    
      
        final 
        def
      
      
        isInstanceOf[T0]: Boolean
      
      
      Test whether the dynamic type of the receiver object is T0.Test whether the dynamic type of the receiver object is T0.Note that the result of the test is modulo Scala's erasure semantics. Therefore the expression 1.isInstanceOf[String]will returnfalse, while the expressionList(1).isInstanceOf[List[String]]will returntrue. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the specified type.- returns
- trueif the receiver object is an instance of erasure of type- T0;- falseotherwise.
 - Definition Classes
- Any
 
- 
      
      
      
        
      
    
      
        final 
        def
      
      
        ne(arg0: AnyRef): Boolean
      
      
      Equivalent to !(this eq that).Equivalent to !(this eq that).- returns
- trueif the argument is not a reference to the receiver object;- falseotherwise.
 - Definition Classes
- AnyRef
 
- 
      
      
      
        
      
    
      
        final 
        def
      
      
        notify(): Unit
      
      
      Wakes up a single thread that is waiting on the receiver object's monitor. Wakes up a single thread that is waiting on the receiver object's monitor. - Definition Classes
- AnyRef
- Note
- not specified by SLS as a member of AnyRef 
 
- 
      
      
      
        
      
    
      
        final 
        def
      
      
        notifyAll(): Unit
      
      
      Wakes up all threads that are waiting on the receiver object's monitor. Wakes up all threads that are waiting on the receiver object's monitor. - Definition Classes
- AnyRef
- Note
- not specified by SLS as a member of AnyRef 
 
- 
      
      
      
        
      
    
      
        final 
        def
      
      
        synchronized[T0](arg0: ⇒ T0): T0
      
      
      - Definition Classes
- AnyRef
 
- 
      
      
      
        
      
    
      
        
        def
      
      
        toString(): String
      
      
      Creates a String representation of this object. Creates a String representation of this object. The default representation is platform dependent. On the java platform it is the concatenation of the class name, "@", and the object's hashcode in hexadecimal. - returns
- a String representation of the object. 
 - Definition Classes
- AnyRef → Any
 
- 
      
      
      
        
      
    
      
        final 
        def
      
      
        wait(): Unit
      
      
      - Definition Classes
- AnyRef
- Annotations
- @throws( ... )
 
- 
      
      
      
        
      
    
      
        final 
        def
      
      
        wait(arg0: Long, arg1: Int): Unit
      
      
      - Definition Classes
- AnyRef
- Annotations
- @throws( ... )
 
- 
      
      
      
        
      
    
      
        final 
        def
      
      
        wait(arg0: Long): Unit
      
      
      - Definition Classes
- AnyRef
- Annotations
- @throws( ... )
 
- 
      
      
      
        
      
    
      
        
        def
      
      
        →[B](y: B): (Annotations, B)
      
      
      - Implicit
- This member is added by an implicit conversion from Annotations to ArrowAssoc[Annotations] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
 
Inherited from AnyRef
Inherited from Any
Inherited by implicit conversion any2stringadd from Annotations to any2stringadd[Annotations]
Inherited by implicit conversion StringFormat from Annotations to StringFormat[Annotations]
Inherited by implicit conversion Ensuring from Annotations to Ensuring[Annotations]
Inherited by implicit conversion ArrowAssoc from Annotations to ArrowAssoc[Annotations]
Annotations
API
The methods available for each reflection entity, without the implementation. Since the reflection entities are later overridden by runtime reflection and macros, their API counterparts guarantee a minimum set of methods that are implemented.
Extractors
Extractors provide the machinery necessary to allow pattern matching and construction of reflection entities that is similar to case classes, although the entities are only abstract types that are later overridden.