Packages

  • package root

    This is the documentation for the Scala standard library.

    This is the documentation for the Scala standard library.

    Package structure

    The scala package contains core types like Int, Float, Array or Option which are accessible in all Scala compilation units without explicit qualification or imports.

    Notable packages include:

    Other packages exist. See the complete list on the right.

    Additional parts of the standard library are shipped as separate libraries. These include:

    • scala.reflect - Scala's reflection API (scala-reflect.jar)
    • scala.xml - XML parsing, manipulation, and serialization (scala-xml.jar)
    • scala.swing - A convenient wrapper around Java's GUI framework called Swing (scala-swing.jar)
    • scala.util.parsing - Parser combinators, including an example implementation of a JSON parser (scala-parser-combinators.jar)

    Automatic imports

    Identifiers in the scala package and the scala.Predef object are always in scope by default.

    Some of these identifiers are type aliases provided as shortcuts to commonly used classes. For example, List is an alias for scala.collection.immutable.List.

    Other aliases refer to classes provided by the underlying platform. For example, on the JVM, String is an alias for java.lang.String.

    Definition Classes
    root
  • package scala

    Core Scala types.

    Core Scala types. They are always available without an explicit import.

    Definition Classes
    root
  • package annotation
    Definition Classes
    scala
  • package meta

    When defining a field, the Scala compiler creates up to four accessors for it: a getter, a setter, and if the field is annotated with @BeanProperty, a bean getter and a bean setter.

    When defining a field, the Scala compiler creates up to four accessors for it: a getter, a setter, and if the field is annotated with @BeanProperty, a bean getter and a bean setter.

    For instance in the following class definition

    class C(@myAnnot @BeanProperty var c: Int)

    there are six entities which can carry the annotation @myAnnot: the constructor parameter, the generated field and the four accessors.

    By default, annotations on (val-, var- or plain) constructor parameters end up on the parameter, not on any other entity. Annotations on fields by default only end up on the field.

    The meta-annotations in package scala.annotation.meta are used to control where annotations on fields and class parameters are copied. This is done by annotating either the annotation type or the annotation class with one or several of the meta-annotations in this package.

    Annotating the annotation type

    The target meta-annotations can be put on the annotation type when instantiating the annotation. In the following example, the annotation @Id will be added only to the bean getter getX.

    import javax.persistence.Id
    class A {
      @(Id @beanGetter) @BeanProperty val x = 0
    }

    In order to annotate the field as well, the meta-annotation @field would need to be added.

    The syntax can be improved using a type alias:

    object ScalaJPA {
      type Id = javax.persistence.Id @beanGetter
    }
    import ScalaJPA.Id
    class A {
      @Id @BeanProperty val x = 0
    }

    Annotating the annotation class

    For annotations defined in Scala, a default target can be specified in the annotation class itself, for example

    @getter
    class myAnnotation extends Annotation

    This only changes the default target for the annotation myAnnotation. When instantiating the annotation, the target can still be specified as described in the last section.

    Definition Classes
    annotation
  • package unchecked
    Definition Classes
    annotation
  • uncheckedStable
  • uncheckedVariance
p

scala.annotation

unchecked

package unchecked

Type Members

  1. final class uncheckedStable extends Annotation with StaticAnnotation

    An annotation for values that are assumed to be stable even though their types are volatile.

    An annotation for values that are assumed to be stable even though their types are volatile.

    Since

    2.7

  2. final class uncheckedVariance extends Annotation with StaticAnnotation

    An annotation for type arguments for which one wants to suppress variance checking types are volatile.

    An annotation for type arguments for which one wants to suppress variance checking types are volatile.

    Since

    2.7

Ungrouped