Scala Annotation List?
Asked Answered
R

4

8

I wanted to ask if there is a list of annotations for Scala 2.8.0? I stumbled upon @inline and @specialized but it would be nice if there is a complete list which also explains what they do exactly.

If such a list doesn't exist: Are there some annotations one should be familiar with?

Renatorenaud answered 26/8, 2010 at 12:47 Comment(0)
C
7

Tour of Scala Annotations: http://www.scala-lang.org/node/106

Internals of Scala Annotations: http://www.scala-lang.org/sid/5

The tour is out of date now. There are several more annotations built into Scala now.

The Known Subclasses section of the Scaladoc for scala.annotation.Annotation provides a fairly significant list (below is as of 2.12.1):

SerialVersionUID, ClassfileAnnotation, StaticAnnotation, TypeConstraint, compileTimeOnly, elidable, implicitAmbiguous, implicitNotFound, beanGetter, beanSetter, companionClass, companionMethod, companionObject, field, getter, languageFeature, param, setter, strictfp, switch, tailrec, uncheckedStable, uncheckedVariance, unspecialized, varargs, BeanDescription, BeanDisplayName, BeanInfoSkip, BeanProperty, BooleanBeanProperty, deprecated, deprecatedInheritance, deprecatedName, deprecatedOverriding, inline, native, noinline, specialized, throws, transient, unchecked, volatile, BeanInfo, remote

SOURCE: http://www.scala-lang.org/api/current/scala/annotation/Annotation.html

Colmar answered 26/8, 2010 at 12:50 Comment(1)
@JosephLust you are correct. I have made note of the shortcomings of the tour and added a reference to the Scaladoc with an excerpt.Weitzel
L
3

It's easy enough to get a list of all Scala annotations. Just go to http://www.scala-lang.org/api/current/scala/annotation/Annotation.html and click on "Known subclasses". Today, I get

BeanDescription, BeanDisplayName, BeanInfo, BeanInfoSkip, BeanProperty, BooleanBeanProperty, ClassfileAnnotation, SerialVersionUID, StaticAnnotation, TypeConstraint, beanGetter, beanSetter, cloneable, cpsParam, deprecated, deprecatedName, elidable, field, getter, implicitNotFound, inline, native, noinline, param, remote, serializable, setter, specialized, strictfp, switch, tailrec, throws, transient, unchecked, uncheckedStable, uncheckedVariance, varargs, volatile

Ligan answered 16/9, 2011 at 4:16 Comment(0)
R
1

To answer my own question:

The official "The Scala Language Specification Version 2.8" actually also has a nice list of annotations in it with some explanation. (Chapter 11, page 133ff.)

Although for example @inline isn't listed there. So it seems not to be complete either.

Renatorenaud answered 26/8, 2010 at 17:45 Comment(0)
S
1

See exhaustive annotation list for Scala 2.12+. Head link, will stay up to date.

Southerland answered 23/3, 2017 at 14:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.