package reflect
- Alphabetic
- By Inheritance
- reflect
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- abstract class AnyValManifest[T <: AnyVal] extends Manifest[T] with Equals
- Annotations
- @nowarn() @SerialVersionUID()
- trait ClassTag[T] extends ClassManifestDeprecatedApis[T] with Equals with Serializable
A
ClassTag[T]
stores the erased class of a given typeT
, accessible via theruntimeClass
field.A
ClassTag[T]
stores the erased class of a given typeT
, accessible via theruntimeClass
field. This is particularly useful for instantiatingArray
s whose element types are unknown at compile time.ClassTag
s are a weaker special case of scala.reflect.api.TypeTags.TypeTags, in that they wrap only the runtime class of a given type, whereas aTypeTag
contains all static type information. That is,ClassTag
s are constructed from knowing only the top-level class of a type, without necessarily knowing all of its argument types. This runtime information is enough for runtimeArray
creation.For example:
scala> def mkArray[T : ClassTag](elems: T*) = Array[T](elems: _*) mkArray: [T](elems: T*)(implicit evidence$1: scala.reflect.ClassTag[T])Array[T] scala> mkArray(42, 13) res0: Array[Int] = Array(42, 13) scala> mkArray("Japan","Brazil","Germany") res1: Array[String] = Array(Japan, Brazil, Germany)
See scala.reflect.api.TypeTags for more examples, or the Reflection Guide: TypeTags for more details.
- Annotations
- @nowarn() @implicitNotFound()
- trait Manifest[T] extends ClassManifest[T] with Equals
A
Manifest[T]
is an opaque descriptor for type T.A
Manifest[T]
is an opaque descriptor for type T. Its supported use is to give access to the erasure of the type as aClass
instance, as is necessary for the creation of nativeArrays
if the class is not known at compile time.The type-relation operators
<:<
and=:=
should be considered approximations only, as there are numerous aspects of type conformance which are not yet adequately represented in manifests.Example usages:
def arr[T] = new Array[T](0) // does not compile def arr[T](implicit m: Manifest[T]) = new Array[T](0) // compiles def arr[T: Manifest] = new Array[T](0) // shorthand for the preceding // Methods manifest and optManifest are in [[scala.Predef]]. def isApproxSubType[T: Manifest, U: Manifest] = manifest[T] <:< manifest[U] isApproxSubType[List[String], List[AnyRef]] // true isApproxSubType[List[String], List[Int]] // false def methods[T: Manifest] = manifest[T].runtimeClass.getMethods def retType[T: Manifest](name: String) = methods[T] find (_.getName == name) map (_.getGenericReturnType) retType[Map[_, _]]("values") // Some(scala.collection.Iterable<B>)
- Annotations
- @nowarn() @implicitNotFound()
- trait OptManifest[+T] extends Serializable
A
OptManifest[T]
is an optional scala.reflect.Manifest.A
OptManifest[T]
is an optional scala.reflect.Manifest.It is either a
Manifest
or the valueNoManifest
.
Deprecated Type Members
- type ClassManifest[T] = ClassTag[T]
A
ClassManifest[T]
is an opaque descriptor for typeT
.A
ClassManifest[T]
is an opaque descriptor for typeT
. It is used by the compiler to preserve information necessary for instantiatingArrays
in those cases where the element type is unknown at compile time.The type-relation operators make an effort to present a more accurate picture than can be realized with erased types, but they should not be relied upon to give correct answers. In particular they are likely to be wrong when variance is involved or when a subtype has a different number of type arguments than a supertype.
- Annotations
- @deprecated @implicitNotFound()
- Deprecated
(Since version 2.10.0) use scala.reflect.ClassTag instead
- trait ClassManifestDeprecatedApis[T] extends OptManifest[T]
- Annotations
- @deprecated
- Deprecated
(Since version 2.10.0) use scala.reflect.ClassTag instead
Value Members
- def classTag[T](implicit ctag: ClassTag[T]): ClassTag[T]
- def ensureAccessible[T <: AccessibleObject](m: T): T
Make a java reflection object accessible, if it is not already and it is possible to do so.
Make a java reflection object accessible, if it is not already and it is possible to do so. If a SecurityException is thrown in the attempt, it is caught and discarded.
- object ClassManifestFactory
ClassManifestFactory
defines factory methods for manifests.ClassManifestFactory
defines factory methods for manifests. It is intended for use by the compiler and should not be used in client code.Unlike
ClassManifest
, this factory isn't annotated with a deprecation warning. This is done to prevent avalanches of deprecation warnings in the code that calls methods with manifests.In a perfect world, we would just remove the @deprecated annotation from
ClassManifest
the object and then delete it in 2.11. After all, that object is explicitly marked as internal, so no one should use it. However a lot of existing libraries disregarded the Scaladoc that comes withClassManifest
, so we need to somehow nudge them into migrating prior to removing stuff out of the blue. Hence we've introduced this design decision as the lesser of two evils.- Annotations
- @nowarn()
- object ClassTag extends java.io.Serializable
Class tags corresponding to primitive types and constructor/extractor for ClassTags.
- object Manifest extends java.io.Serializable
The object
Manifest
defines factory methods for manifests.The object
Manifest
defines factory methods for manifests. It is intended for use by the compiler and should not be used in client code. - object ManifestFactory
ManifestFactory
defines factory methods for manifests.ManifestFactory
defines factory methods for manifests. It is intended for use by the compiler and should not be used in client code.Unlike
Manifest
, this factory isn't annotated with a deprecation warning. This is done to prevent avalanches of deprecation warnings in the code that calls methods with manifests. Why so complicated? Read up the comments forClassManifestFactory
.- Annotations
- @nowarn()
- object NameTransformer
Provides functions to encode and decode Scala symbolic names.
Provides functions to encode and decode Scala symbolic names. Also provides some constants.
- object NoManifest extends OptManifest[Nothing] with Serializable
One of the branches of an scala.reflect.OptManifest.
Deprecated Value Members
- val ClassManifest: ClassManifestFactory.type
The object
ClassManifest
defines factory methods for manifests.The object
ClassManifest
defines factory methods for manifests. It is intended for use by the compiler and should not be used in client code.- Annotations
- @deprecated
- Deprecated
(Since version 2.10.0) use scala.reflect.ClassTag instead
This is the documentation for the Scala standard library.
Package structure
The scala package contains core types like
Int
,Float
,Array
orOption
which are accessible in all Scala compilation units without explicit qualification or imports.Notable packages include:
scala.collection
and its sub-packages contain Scala's collections frameworkscala.collection.immutable
- Immutable, sequential data-structures such asVector
,List
,Range
,HashMap
orHashSet
scala.collection.mutable
- Mutable, sequential data-structures such asArrayBuffer
,StringBuilder
,HashMap
orHashSet
scala.collection.concurrent
- Mutable, concurrent data-structures such asTrieMap
scala.concurrent
- Primitives for concurrent programming such asFutures
andPromises
scala.io
- Input and output operationsscala.math
- Basic math functions and additional numeric types likeBigInt
andBigDecimal
scala.sys
- Interaction with other processes and the operating systemscala.util.matching
- Regular expressionsOther 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.collection.parallel
- Parallel collections (scala-parallel-collections.jar)scala.util.parsing
- Parser combinators (scala-parser-combinators.jar)scala.swing
- A convenient wrapper around Java's GUI framework called Swing (scala-swing.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 forscala.collection.immutable.List
.Other aliases refer to classes provided by the underlying platform. For example, on the JVM,
String
is an alias forjava.lang.String
.