Information about an annotation.
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.
This "virtual" case class represents the reflection interface for literal expressions which can not be further broken down or evaluated, such as "true", "0", "classOf[List]". Such values become parts of the Scala abstract syntax tree representing the program. The constants correspond to section 6.24 "Constant Expressions" of the Scala Language Specification.
Such constants are used to represent literals in abstract syntax trees (the scala.reflect.api.Trees#Literal node) and literal arguments for Java class file annotations (the scala.reflect.api.Annotations#LiteralArgument class).
Constants can be matched against and can be constructed directly, as if they were case classes:
assert(Constant(true).value == true) Constant(true) match { case Constant(s: String) => println("A string: " + s) case Constant(b: Boolean) => println("A boolean value: " + b) case Constant(x) => println("Something else: " + x) }
Constant
instances can wrap certain kinds of these expressions:
Byte
, Short
, Int
, Long
, Float
, Double
, Char
, Boolean
and Unit
) - represented directly as the corresponding typeString literals - represented as instances of the String
.References to classes, typically constructed with scala.Predef#classOf - represented as types.References to enumeration values - represented as symbols. Class references are represented as instances of scala.reflect.api.Types#Type (because when the Scala compiler processes a class reference, the underlying runtime class might not yet have been compiled). To convert such a reference to a runtime class, one should use the runtimeClass
method of a mirror such as RuntimeMirror
(the simplest way to get such a mirror is using scala.reflect.runtime.currentMirror
).
Enumeration value references are represented as instances of scala.reflect.api.Symbols#Symbol, which on JVM point to methods that return underlying enum values. To inspect an underlying enumeration or to get runtime value of a reference to an enum, one should use a scala.reflect.api.Mirrors#RuntimeMirror (the simplest way to get such a mirror is again scala.reflect.runtime.package#currentMirror).
Usage example:
enum JavaSimpleEnumeration { FOO, BAR } import java.lang.annotation.*; @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) public @interface JavaSimpleAnnotation { Class<?> classRef(); JavaSimpleEnumeration enumRef(); } @JavaSimpleAnnotation( classRef = JavaAnnottee.class, enumRef = JavaSimpleEnumeration.BAR ) public class JavaAnnottee {}
import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} object Test extends App { val jann = typeOf[JavaAnnottee].typeSymbol.annotations(0).javaArgs def jarg(name: String) = jann(TermName(name)) match { // Constant is always wrapped into a Literal or LiteralArgument tree node case LiteralArgument(ct: Constant) => value } val classRef = jarg("classRef").value.asInstanceOf[Type] // ideally one should match instead of casting println(showRaw(classRef)) // TypeRef(ThisType(<empty>), JavaAnnottee, List()) println(cm.runtimeClass(classRef)) // class JavaAnnottee val enumRef = jarg("enumRef").value.asInstanceOf[Symbol] // ideally one should match instead of casting println(enumRef) // value BAR val siblings = enumRef.owner.info.decls val enumValues = siblings.filter(sym => sym.isVal && sym.isPublic) println(enumValues) // Scope{ // final val FOO: JavaSimpleEnumeration; // final val BAR: JavaSimpleEnumeration // } // doesn't work because of https://github.com/scala/bug/issues/6459 // val enumValue = mirror.reflectField(enumRef.asTerm).get val enumClass = cm.runtimeClass(enumRef.owner.asClass) val enumValue = enumClass.getDeclaredField(enumRef.name.toString).get(null) println(enumValue) // BAR }
An extractor class to create and pattern match with syntax Constant(value)
where value
is the Scala value of the constant.
Expr wraps an abstract syntax tree and tags it with its type. The main source of information about exprs is the scala.reflect.api.Exprs page.
The API of FlagSet
instances. The main source of information about flag sets is the scala.reflect.api.FlagSets page.
An abstract type representing sets of flags (like private, final, etc.) that apply to definition trees and symbols
All possible values that can constitute flag sets. The main source of information about flag sets is the scala.reflect.api.FlagSets page.
The type of free terms introduced by reification.
The API of free term symbols. The main source of information about symbols is the Symbols page.
$SYMACCESSORS
The type of free types introduced by reification.
The API of free type symbols. The main source of information about symbols is the Symbols page.
$SYMACCESSORS
This trait provides support for importers, a facility to migrate reflection artifacts between universes. Note: this trait should typically be used only rarely.
Reflection artifacts, such as Symbols and Types, are contained in Universes. Typically all processing happens within a single Universe
(e.g. a compile-time macro Universe
or a runtime reflection Universe
), but sometimes there is a need to migrate artifacts from one Universe
to another. For example, runtime compilation works by importing runtime reflection trees into a runtime compiler universe, compiling the importees and exporting the result back.
Reflection artifacts are firmly grounded in their Universe
s, which is reflected by the fact that types of artifacts from different universes are not compatible. By using Importer
s, however, they be imported from one universe into another. For example, to import foo.bar.Baz
from the source Universe
to the target Universe
, an importer will first check whether the entire owner chain exists in the target Universe
. If it does, then nothing else will be done. Otherwise, the importer will recreate the entire owner chain and will import the corresponding type signatures into the target Universe
.
Since importers match Symbol
tables of the source and the target Universe
s using plain string names, it is programmer's responsibility to make sure that imports don't distort semantics, e.g., that foo.bar.Baz
in the source Universe
means the same that foo.bar.Baz
does in the target Universe
.
Here's how one might implement a macro that performs compile-time evaluation of its argument by using a runtime compiler to compile and evaluate a tree that belongs to a compile-time compiler:
def staticEval[T](x: T) = macro staticEval[T] def staticEval[T](c: scala.reflect.macros.blackbox.Context)(x: c.Expr[T]) = { // creates a runtime reflection universe to host runtime compilation import scala.reflect.runtime.{universe => ru} val mirror = ru.runtimeMirror(c.libraryClassLoader) import scala.tools.reflect.ToolBox val toolBox = mirror.mkToolBox() // runtime reflection universe and compile-time macro universe are different // therefore an importer is needed to bridge them // currently mkImporter requires a cast to correctly assign the path-dependent types val importer0 = ru.internal.mkImporter(c.universe) val importer = importer0.asInstanceOf[ru.internal.Importer { val from: c.universe.type }] // the created importer is used to turn a compiler tree into a runtime compiler tree // both compilers use the same classpath, so semantics remains intact val imported = importer.importTree(tree) // after the tree is imported, it can be evaluated as usual val tree = toolBox.untypecheck(imported.duplicate) val valueOfX = toolBox.eval(imported).asInstanceOf[T] ... }
Reflection API exhibits a tension inherent to experimental things: on the one hand we want it to grow into a beautiful and robust API, but on the other hand we have to deal with immaturity of underlying mechanisms by providing not very pretty solutions to enable important use cases.
In Scala 2.10, which was our first stab at reflection API, we didn't have a systematic approach to dealing with this tension, sometimes exposing too much of internals (e.g. Symbol.deSkolemize) and sometimes exposing too little (e.g. there's still no facility to change owners, to do typing transformations, etc). This resulted in certain confusion with some internal APIs living among public ones, scaring the newcomers, and some internal APIs only available via casting, which requires intimate knowledge of the compiler and breaks compatibility guarantees.
This led to creation of the internal
API module for the reflection API, which provides advanced APIs necessary for macros that push boundaries of the state of the art, clearly demarcating them from the more or less straightforward rest and providing compatibility guarantees on par with the rest of the reflection API (full compatibility within minor releases, best effort towards backward compatibility within major releases, clear replacement path in case of rare incompatible changes in major releases).
The internal
module itself (the value that implements InternalApi) isn't defined here, in scala.reflect.api.Universe, but is provided on per-implementation basis. Runtime API endpoint (scala.reflect.runtime.universe) provides universe.compat: InternalApi
, whereas compile-time API endpoints (instances of scala.reflect.macros.Context) provide c.compat: ContextInternalApi
, which extends InternalApi
with additional universe-specific and context-specific functionality.
Marks underlying reference to id as boxed.
Precondition: id must refer to a captured variable A reference such marked will refer to the boxed entity, no dereferencing with `.elem` is done on it. This tree node can be emitted by macros such as reify that call referenceCapturedVariable. It is eliminated in LambdaLift, where the boxing conversion takes place.
The API that all references support
An extractor class to create and pattern match with syntax ReferenceToBoxed(ident)
. This AST node does not have direct correspondence to Scala code, and is emitted by macros to reference capture vars directly without going through elem
.
For example:
var x = ... fun { x }
Will emit:
Ident(x)
Which gets transformed to:
Select(Ident(x), "elem")
If ReferenceToBoxed
were used instead of Ident, no transformation would be performed.
This is an internal implementation class.
A refinement of scala.reflect.api.Mirror for runtime reflection using JVM classloaders.
With this upgrade, mirrors become capable of converting Scala reflection artifacts (symbols and types) into Java reflection artifacts (classes) and vice versa. Consequently, refined mirrors become capable of performing reflective invocations (getting/setting field values, calling methods, etc).
For more information about Mirrors
s, see scala.reflect.api.Mirrors or the Reflection Guide: Mirrors
In runtime reflection universes, mirrors are JavaMirrors
.
The type of tree modifiers (not a tree, but rather part of DefTrees).
The abstract type of names.
Defines a universe-specific notion of positions. The main documentation entry about positions is located at scala.reflect.api.Position.
In runtime reflection universes, runtime representation of a class is java.lang.Class
.
The abstract type of names representing types.
The abstract type of names representing terms.
A type class that defines a representation of T
as a Tree
.
http://docs.scala-lang.org/overviews/quasiquotes/lifting.html
A type class that defines a way to extract instance of T
from a Tree
.
http://docs.scala-lang.org/overviews/quasiquotes/unlifting.html
A mirror that reflects the instance parts of a runtime class. See the overview page for details on how to use runtime reflection.
A mirror that reflects a field. See the overview page for details on how to use runtime reflection.
A mirror that reflects a runtime value. See the overview page for details on how to use runtime reflection.
A mirror that reflects a method. See the overview page for details on how to use runtime reflection.
A mirror that reflects a Scala object definition or the static parts of a runtime class. See the overview page for details on how to use runtime reflection.
A mirror that reflects instances and static classes. See the overview page for details on how to use runtime reflection.
Has no special methods. Is here to provides erased identity for RuntimeClass
.
The API of a mirror for a reflective universe. See the overview page for details on how to use runtime reflection.
A mirror that reflects the instance or static parts of a runtime class. See the overview page for details on how to use runtime reflection.
The API of Name instances.
Has no special methods. Is here to provides erased identity for TermName
.
An extractor class to create and pattern match with syntax TermName(s)
.
Has no special methods. Is here to provides erased identity for TypeName
.
An extractor class to create and pattern match with syntax TypeName(s)
.
Implicit class that introduces q
, tq
, cq,
pq
and fq
string interpolators that are also known as quasiquotes. With their help you can easily manipulate Scala reflection ASTs.
The type of member scopes, as in class definitions, for example.
The API that all member scopes support
The base type of all scopes.
The API that all scopes support
Defines standard symbols (and types via its base trait).
Defines standard types.
Defines standard names, common for term and type names: These can be accessed via the nme and tpnme members.
Defines standard term names that can be accessed via the nme member.
Defines standard type names that can be accessed via the tpnme member.
The type of class symbols representing class and trait definitions.
The API of class symbols. The main source of information about symbols is the Symbols page.
Class Symbol defines isXXX
test methods such as isPublic
or isFinal
, params
and returnType
methods for method symbols, baseClasses
for class symbols and so on. Some of these methods don't make sense for certain subclasses of Symbol
and return NoSymbol
, Nil
or other empty values.
The type of method symbols representing def declarations.
The API of method symbols. The main source of information about symbols is the Symbols page.
Class Symbol defines isXXX
test methods such as isPublic
or isFinal
, params
and returnType
methods for method symbols, baseClasses
for class symbols and so on. Some of these methods don't make sense for certain subclasses of Symbol
and return NoSymbol
, Nil
or other empty values.
The type of module symbols representing object declarations.
The API of module symbols. The main source of information about symbols is the Symbols page.
Class Symbol defines isXXX
test methods such as isPublic
or isFinal
, params
and returnType
methods for method symbols, baseClasses
for class symbols and so on. Some of these methods don't make sense for certain subclasses of Symbol
and return NoSymbol
, Nil
or other empty values.
The type of symbols representing declarations.
The API of symbols. The main source of information about symbols is the Symbols page.
Class Symbol defines isXXX
test methods such as isPublic
or isFinal
, params
and returnType
methods for method symbols, baseClasses
for class symbols and so on. Some of these methods don't make sense for certain subclasses of Symbol
and return NoSymbol
, Nil
or other empty values.
The type of term symbols representing val, var, def, and object declarations as well as packages and value parameters.
The API of term symbols. The main source of information about symbols is the Symbols page.
Class Symbol defines isXXX
test methods such as isPublic
or isFinal
, params
and returnType
methods for method symbols, baseClasses
for class symbols and so on. Some of these methods don't make sense for certain subclasses of Symbol
and return NoSymbol
, Nil
or other empty values.
The type of type symbols representing type, class, and trait declarations, as well as type parameters.
The API of type symbols. The main source of information about symbols is the Symbols page.
Class Symbol defines isXXX
test methods such as isPublic
or isFinal
, params
and returnType
methods for method symbols, baseClasses
for class symbols and so on. Some of these methods don't make sense for certain subclasses of Symbol
and return NoSymbol
, Nil
or other empty values.
Alternatives of patterns.
Eliminated by compiler phases Eliminated by compiler phases patmat (in the new pattern matcher of 2.10) or explicitouter (in the old pre-2.10 pattern matcher), except for occurrences in encoded Switch stmt (i.e. remaining Match(CaseDef(...)))
The API that all alternatives support
An extractor class to create and pattern match with syntax Alternative(trees)
. This AST node corresponds to the following Scala code:
pat1 | ... | patn
A tree that has an annotation attached to it. Only used for annotated types and annotation ascriptions, annotations on definitions are stored in the Modifiers. Eliminated by typechecker (typedAnnotated), the annotations are then stored in an AnnotatedType.
The API that all annotateds support
An extractor class to create and pattern match with syntax Annotated(annot, arg)
. This AST node corresponds to the following Scala code:
arg @annot // for types arg: @annot // for exprs
Applied type <tpt> [ <args> ], eliminated by RefCheck
The API that all applied type trees support
An extractor class to create and pattern match with syntax AppliedTypeTree(tpt, args)
. This AST node corresponds to the following Scala code:
tpt[args]
Should only be used with tpt
nodes which are types, i.e. which have isType
returning true
. Otherwise TypeApply
should be used instead.
List[Int] as in val x: List[Int] = ???
// represented as AppliedTypeTree(Ident(<List>), List(TypeTree(<Int>)))
def foo[T] = ??? foo[Int] // represented as TypeApply(Ident(<foo>), List(TypeTree(<Int>)))
Value application
The API that all applies support
An extractor class to create and pattern match with syntax Apply(fun, args)
. This AST node corresponds to the following Scala code:
fun(args)
For instance:
fun[targs](args)
Is expressed as:
Apply(TypeApply(fun, targs), args)
Assignment
The API that all assigns support
An extractor class to create and pattern match with syntax Assign(lhs, rhs)
. This AST node corresponds to the following Scala code:
lhs = rhs
Bind a variable to a rhs pattern.
Eliminated by compiler phases patmat (in the new pattern matcher of 2.10) or explicitouter (in the old pre-2.10 pattern matcher).
The API that all binds support
An extractor class to create and pattern match with syntax Bind(name, body)
. This AST node corresponds to the following Scala code:
pat*
Block of expressions (semicolon separated expressions)
The API that all blocks support
An extractor class to create and pattern match with syntax Block(stats, expr)
. This AST node corresponds to the following Scala code:
{ stats; expr }
If the block is empty, the expr
is set to Literal(Constant(()))
.
Case clause in a pattern match. (except for occurrences in switch statements). Eliminated by compiler phases patmat (in the new pattern matcher of 2.10) or explicitouter (in the old pre-2.10 pattern matcher)
The API that all case defs support
An extractor class to create and pattern match with syntax CaseDef(pat, guard, body)
. This AST node corresponds to the following Scala code:
case
pat if
guard => body
If the guard is not present, the guard
is set to EmptyTree
. If the body is not specified, the body
is set to Literal(Constant(()))
A class definition.
The API that all class defs support
An extractor class to create and pattern match with syntax ClassDef(mods, name, tparams, impl)
. This AST node corresponds to the following Scala code:
mods class
name [tparams] impl
Where impl stands for:
extends
parents { defs }
Intersection type <parent1> with ... with <parentN> { <decls> }, eliminated by RefCheck
The API that all compound type trees support
An extractor class to create and pattern match with syntax CompoundTypeTree(templ)
. This AST node corresponds to the following Scala code:
parent1 with ... with parentN { refinement }
A method or macro definition.
The API that all def defs support
An extractor class to create and pattern match with syntax DefDef(mods, name, tparams, vparamss, tpt, rhs)
. This AST node corresponds to the following Scala code:
mods def
name[tparams](vparams_1)...(vparams_n): tpt = rhs
If the return type is not specified explicitly (i.e. is meant to be inferred), this is expressed by having tpt
set to TypeTree()
(but not to an EmptyTree
!).
A tree representing a symbol-defining entity: 1) A declaration or a definition (type, class, object, package, val, var, or def) 2) Bind
that is used to represent binding occurrences in pattern matches 3) LabelDef
that is used internally to represent while loops
The API that all def trees support
Existential type tree node
The API that all existential type trees support
An extractor class to create and pattern match with syntax ExistentialTypeTree(tpt, whereClauses)
. This AST node corresponds to the following Scala code:
tpt forSome { whereClauses }
Anonymous function, eliminated by compiler phase lambdalift
The API that all functions support
An extractor class to create and pattern match with syntax Function(vparams, body)
. This AST node corresponds to the following Scala code:
vparams => body
The symbol of a Function is a synthetic TermSymbol. It is the owner of the function's parameters.
Common base class for Apply and TypeApply.
The API that all applies support
A reference to identifier name
.
The API that all idents support
An extractor class to create and pattern match with syntax Ident(qual, name)
. This AST node corresponds to the following Scala code:
name
Type checker converts idents that refer to enclosing fields or methods to selects. For example, name ==> this.name
Conditional expression
The API that all ifs support
An extractor class to create and pattern match with syntax If(cond, thenp, elsep)
. This AST node corresponds to the following Scala code:
if
(cond) thenp else
elsep
If the alternative is not present, the elsep
is set to Literal(Constant(()))
.
A common base class for class and object definitions.
The API that all impl defs support
Import clause
The API that all imports support
An extractor class to create and pattern match with syntax Import(expr, selectors)
. This AST node corresponds to the following Scala code:
import expr.{selectors}
Selectors are a list of ImportSelectors, which conceptually are pairs of names (from, to). The last (and maybe only name) may be a nme.WILDCARD. For instance:
import qual.{w => _, x, y => z, _}
Would be represented as:
Import(qual, List(("w", WILDCARD), ("x", "x"), ("y", "z"), (WILDCARD, null)))
The symbol of an Import
is an import symbol @see Symbol.newImport. It's used primarily as a marker to check that the import has been typechecked.
Import selector (not a tree, but a component of the Import
tree)
Representation of an imported name its optional rename and their optional positions
Eliminated by typecheck.
The API that all import selectors support
An extractor class to create and pattern match with syntax ImportSelector(name, namePos, rename, renamePos)
. This is not an AST node, it is used as a part of the Import
node.
A labelled expression. Not expressible in language syntax, but generated by the compiler to simulate while/do-while loops, and also by the pattern matcher.
The label acts much like a nested function, where params
represents the incoming parameters. The symbol given to the LabelDef should have a MethodType, as if it were a nested function.
Jumps are apply nodes attributed with a label's symbol. The arguments from the apply node will be passed to the label and assigned to the Idents.
Forward jumps within a block are allowed.
The API that all label defs support
An extractor class to create and pattern match with syntax LabelDef(name, params, rhs)
.
This AST node does not have direct correspondence to Scala code. It is used for tailcalls and like. For example, while/do are desugared to label defs as follows:
while (cond) body ==> LabelDef($L, List(), if (cond) { body; L$() } else ())
do body while (cond) ==> LabelDef($L, List(), body; if (cond) L$() else ())
Literal
The API that all literals support
An extractor class to create and pattern match with syntax Literal(value)
. This AST node corresponds to the following Scala code:
value
- Pattern matching expression (before compiler phase explicitouter before 2.10 / patmat from 2.10)
After compiler phase explicitouter before 2.10 / patmat from 2.10, cases will satisfy the following constraints:
EmptyTree
,all patterns will be either Literal(Constant(x:Int))
or Alternative(lit|...|lit)
except for an "otherwise" branch, which has pattern Ident(nme.WILDCARD)
The API that all matches support
An extractor class to create and pattern match with syntax Match(selector, cases)
. This AST node corresponds to the following Scala code:
selector match
{ cases }
Match
is also used in pattern matching assignments like val (foo, bar) = baz
.
Common base class for all member definitions: types, classes, objects, packages, vals and vars, defs.
The API that all member defs support
The API that all Modifiers support
An extractor class to create and pattern match with syntax Modifiers(flags, privateWithin, annotations)
. Modifiers encapsulate flags, visibility annotations and Scala annotations for member definitions.
An object definition, e.g. object Foo
. Internally, objects are quite frequently called modules to reduce ambiguity. Eliminated by compiler phase refcheck.
The API that all module defs support
An extractor class to create and pattern match with syntax ModuleDef(mods, name, impl)
. This AST node corresponds to the following Scala code:
mods object
name impl
Where impl stands for:
extends
parents { defs }
A tree that carries a name, e.g. by defining it (DefTree
) or by referring to it (RefTree
).
The API that all name trees support
Either an assignment or a named argument. Only appears in argument lists, eliminated by compiler phase typecheck (doTypedApply), resurrected by reifier.
The API that all assigns support
An extractor class to create and pattern match with syntax NamedArg(lhs, rhs)
. This AST node corresponds to the following Scala code:
m.f(lhs = rhs)
@annotation(lhs = rhs)
Object instantiation
The API that all news support
An extractor class to create and pattern match with syntax New(tpt)
. This AST node corresponds to the following Scala code:
new
T
This node always occurs in the following context:
(new
tpt).<init>[targs](args)
For example, an AST representation of:
new Example[Int](2)(3)
is the following code:
Apply( Apply( TypeApply( Select(New(TypeTree(typeOf[Example])), nme.CONSTRUCTOR) TypeTree(typeOf[Int])), List(Literal(Constant(2)))), List(Literal(Constant(3))))
A packaging, such as package pid { stats }
The API that all package defs support
An extractor class to create and pattern match with syntax PackageDef(pid, stats)
. This AST node corresponds to the following Scala code:
package
pid { stats }
A tree which references a symbol-carrying entity. References one, as opposed to defining one; definitions are in DefTrees.
The API that all ref trees support
An extractor class to create and pattern match with syntax RefTree(qual, name)
. This AST node corresponds to either Ident, Select or SelectFromTypeTree.
Return expression
The API that all returns support
An extractor class to create and pattern match with syntax Return(expr)
. This AST node corresponds to the following Scala code:
return
expr
The symbol of a Return node is the enclosing method.
A member selection <qualifier> . <name>
The API that all selects support
An extractor class to create and pattern match with syntax Select(qual, name)
. This AST node corresponds to the following Scala code:
qualifier.selector
Should only be used with qualifier
nodes which are terms, i.e. which have isTerm
returning true
. Otherwise SelectFromTypeTree
should be used instead.
foo.Bar // represented as Select(Ident(<foo>), <Bar>) Foo#Bar // represented as SelectFromTypeTree(Ident(<Foo>), <Bar>)
Type selection <qualifier> # <name>, eliminated by RefCheck
The API that all selects from type trees support
An extractor class to create and pattern match with syntax SelectFromTypeTree(qualifier, name)
. This AST node corresponds to the following Scala code:
qualifier # selector
Note: a path-dependent type p.T is expressed as p.type # T
Should only be used with qualifier
nodes which are types, i.e. which have isType
returning true
. Otherwise Select
should be used instead.
Foo#Bar // represented as SelectFromTypeTree(Ident(<Foo>), <Bar>) foo.Bar // represented as Select(Ident(<foo>), <Bar>)
Singleton type, eliminated by RefCheck
The API that all singleton type trees support
An extractor class to create and pattern match with syntax SingletonTypeTree(ref)
. This AST node corresponds to the following Scala code:
ref.type
Repetition of pattern.
Eliminated by compiler phases patmat (in the new pattern matcher of 2.10) or explicitouter (in the old pre-2.10 pattern matcher).
The API that all stars support
An extractor class to create and pattern match with syntax Star(elem)
. This AST node corresponds to the following Scala code:
pat*
Super reference, where qual
is the corresponding this
reference. A super reference C.super[M]
is represented as Super(This(C), M)
.
The API that all supers support
An extractor class to create and pattern match with syntax Super(qual, mix)
. This AST node corresponds to the following Scala code:
C.super[M]
Which is represented as:
Super(This(C), M)
If mix
is empty, it is tpnme.EMPTY.
The symbol of a Super is the class _from_ which the super reference is made. For instance in C.super(...), it would be C.
A tree that carries a symbol, e.g. by defining it (DefTree
) or by referring to it (RefTree
). Such trees start their life naked, returning NoSymbol
, but after being typechecked without errors they hold non-empty symbols.
The API that all sym trees support
Instantiation template of a class or trait
The API that all templates support
An extractor class to create and pattern match with syntax Template(parents, self, body)
. This AST node corresponds to the following Scala code:
extends
parents { self => body }
In case when the self-type annotation is missing, it is represented as an empty value definition with nme.WILDCARD as name and NoType as type.
The symbol of a template is a local dummy. @see Symbol.newLocalDummy The owner of the local dummy is the enclosing trait or class. The local dummy is itself the owner of any local blocks. For example:
class C { def foo { // owner is C def bar // owner is local dummy } }
A tree for a term. Not all trees representing terms are TermTrees; use isTerm to reliably identify terms.
The API that all term trees support
Self reference
The API that all thises support
An extractor class to create and pattern match with syntax This(qual)
. This AST node corresponds to the following Scala code:
qual.this
The symbol of a This is the class to which the this refers. For instance in C.this, it would be C.
Throw expression
The API that all tries support
An extractor class to create and pattern match with syntax Throw(expr)
. This AST node corresponds to the following Scala code:
throw
expr
A class that implement a default tree transformation strategy: breadth-first component-wise cloning.
A class that implement a default tree traversal strategy: breadth-first component-wise.
The type of Scala abstract syntax trees.
The API that all trees support. The main source of information about trees is the scala.reflect.api.Trees page.
The type of standard (lazy) tree copiers.
The API of a tree copier.
Try catch node
The API that all tries support
An extractor class to create and pattern match with syntax Try(block, catches, finalizer)
. This AST node corresponds to the following Scala code:
try
block catch
{ catches } finally
finalizer
If the finalizer is not present, the finalizer
is set to EmptyTree
.
A tree for a type. Not all trees representing types are TypTrees; use isType to reliably identify types.
The API that all typ trees support
Explicit type application.
The API that all type applies support
An extractor class to create and pattern match with syntax TypeApply(fun, args)
. This AST node corresponds to the following Scala code:
fun[args]
Should only be used with fun
nodes which are terms, i.e. which have isTerm
returning true
. Otherwise AppliedTypeTree
should be used instead.
def foo[T] = ??? foo[Int] // represented as TypeApply(Ident(<foo>), List(TypeTree(<Int>)))
List[Int] as in val x: List[Int] = ???
// represented as AppliedTypeTree(Ident(<List>), List(TypeTree(<Int>)))
Type bounds tree node
The API that all type bound trees support
An extractor class to create and pattern match with syntax TypeBoundsTree(lo, hi)
. This AST node corresponds to the following Scala code:
>: lo <: hi
An abstract type, a type parameter, or a type alias. Eliminated by erasure.
The API that all type defs support
An extractor class to create and pattern match with syntax TypeDef(mods, name, tparams, rhs)
. This AST node corresponds to the following Scala code:
mods type
name[tparams] = rhs
mods type
name[tparams] >: lo <: hi
First usage illustrates TypeDefs
representing type aliases and type parameters. Second usage illustrates TypeDefs
representing abstract types, where lo and hi are both TypeBoundsTrees
and Modifier.deferred
is set in mods.
A synthetic tree holding an arbitrary type. Not to be confused with with TypTree, the trait for trees that are only used for type trees. TypeTree's are inserted in several places, but most notably in RefCheck
, where the arbitrary type trees are all replaced by TypeTree's.
The API that all type trees support
An extractor class to create and pattern match with syntax TypeTree()
. This AST node does not have direct correspondence to Scala code, and is emitted by everywhere when we want to wrap a Type
in a Tree
.
Type annotation, eliminated by compiler phase cleanup
The API that all typeds support
An extractor class to create and pattern match with syntax Typed(expr, tpt)
. This AST node corresponds to the following Scala code:
expr: tpt
Used to represent unapply
methods in pattern matching.
For example:
2 match { case Foo(x) => x }
Is represented as:
Match( Literal(Constant(2)), List( CaseDef( UnApply( // a dummy node that carries the type of unapplication to patmat // the <unapply-selector> here doesn't have an underlying symbol // it only has a type assigned, therefore after `untypecheck` this tree is no longer typeable Apply(Select(Ident(Foo), TermName("unapply")), List(Ident(TermName("<unapply-selector>")))), // arguments of the unapply => nothing synthetic here List(Bind(TermName("x"), Ident(nme.WILDCARD)))), EmptyTree, Ident(TermName("x")))))
Introduced by typer. Eliminated by compiler phases patmat (in the new pattern matcher of 2.10) or explicitouter (in the old pre-2.10 pattern matcher).
The API that all unapplies support
An extractor class to create and pattern match with syntax UnApply(fun, args)
. This AST node does not have direct correspondence to Scala code, and is introduced when typechecking pattern matches and try
blocks.
Broadly speaking, a value definition. All these are encoded as ValDefs:
The API that all val defs support
An extractor class to create and pattern match with syntax ValDef(mods, name, tpt, rhs)
. This AST node corresponds to any of the following Scala code:
mods val
name: tpt = rhs
mods var
name: tpt = rhs
mods name: tpt = rhs // in signatures of function and method definitions
self: Bar => // self-types
If the type of a value is not specified explicitly (i.e. is meant to be inferred), this is expressed by having tpt
set to TypeTree()
(but not to an EmptyTree
!).
A common base class for ValDefs and DefDefs.
The API that all val defs and def defs support
A TypeTag
is a scala.reflect.api.TypeTags#WeakTypeTag with the additional static guarantee that all type references are concrete, i.e. it does not contain any references to unresolved type parameters or abstract types.
If an implicit value of type WeakTypeTag[T]
is required, the compiler will create one, and the reflective representation of T
can be accessed via the tpe
field. Components of T
can be references to type parameters or abstract types. Note that WeakTypeTag
makes an effort to be as concrete as possible, i.e. if TypeTag
s are available for the referenced type arguments or abstract types, they are used to embed the concrete types into the WeakTypeTag. Otherwise the WeakTypeTag will contain a reference to an abstract type. This behavior can be useful, when one expects T
to be perhaps be partially abstract, but requires special care to handle this case. However, if T
is expected to be fully known, use scala.reflect.api.TypeTags#TypeTag instead, which statically guarantees this property.
For more information about TypeTag
s, see the Reflection Guide: TypeTags
The AnnotatedType
type signature is used for annotated types of the for <type> @<annotation>
.
The API that all annotated types support. The main source of information about types is the scala.reflect.api.Types page.
An extractor class to create and pattern match with syntax AnnotatedType(annotations, underlying)
. Here, annotations
are the annotations decorating the underlying type underlying
. selfSym
is a symbol representing the annotated type itself.
BoundedWildcardTypes, used only during type inference, are created in two places:
The API that all this types support. The main source of information about types is the scala.reflect.api.Types page.
An extractor class to create and pattern match with syntax BoundedWildcardTypeExtractor(bounds)
with bounds
denoting the type bounds.
The ClassInfo
type signature is used to define parents and declarations of classes, traits, and objects. If a class, trait, or object C is declared like this
C extends P_1 with ... with P_m { D_1; ...; D_n}
its ClassInfo
type has the following form:
ClassInfo(List(P_1, ..., P_m), Scope(D_1, ..., D_n), C)
The API that all class info types support. The main source of information about types is the scala.reflect.api.Types page.
An extractor class to create and pattern match with syntax ClassInfo(parents, decls, clazz)
Here, parents
is the list of parent types of the class, decls
is the scope containing all declarations in the class, and clazz
is the symbol of the class itself.
A subtype of Type representing refined types as well as ClassInfo
signatures.
Has no special methods. Is here to provides erased identity for CompoundType
.
A ConstantType
type cannot be expressed in user programs; it is inferred as the type of a constant. Here are some constants with their types and the internal string representation:
1 ConstantType(Constant(1)) Int(1) "abc" ConstantType(Constant("abc")) String("abc")
ConstantTypes denote values that may safely be constant folded during type checking. The deconst
operation returns the equivalent type that will not be constant folded.
The API that all constant types support. The main source of information about types is the scala.reflect.api.Types page.
An extractor class to create and pattern match with syntax ConstantType(constant)
Here, constant
is the constant value represented by the type.
The ExistentialType
type signature is used for existential types and wildcard types.
The API that all existential types support. The main source of information about types is the scala.reflect.api.Types page.
An extractor class to create and pattern match with syntax ExistentialType(quantified, underlying)
. Here, quantified
are the type variables bound by the existential type and underlying
is the type that's existentially quantified.
The MethodType
type signature is used to indicate parameters and result type of a method
The API that all method types support. The main source of information about types is the scala.reflect.api.Types page.
An extractor class to create and pattern match with syntax MethodType(params, restpe)
Here, params
is a potentially empty list of parameter symbols of the method, and restpe
is the result type of the method. If the method is curried, restpe
would be another MethodType
. Note: MethodType(Nil, Int)
would be the type of a method defined with an empty parameter list.
def f(): Int
If the method is completely parameterless, as in
def f: Int
its type is a NullaryMethodType
.
The NullaryMethodType
type signature is used for parameterless methods with declarations of the form def foo: T
The API that all nullary method types support. The main source of information about types is the scala.reflect.api.Types page.
An extractor class to create and pattern match with syntax NullaryMethodType(resultType)
. Here, resultType
is the result type of the parameterless method.
The PolyType
type signature is used for polymorphic methods that have at least one type parameter.
The API that all polymorphic types support. The main source of information about types is the scala.reflect.api.Types page.
An extractor class to create and pattern match with syntax PolyType(typeParams, resultType)
. Here, typeParams
are the type parameters of the method and resultType
is the type signature following the type parameters.
The RefinedType
type defines types of any of the forms on the left, with their RefinedType representations to the right.
P_1 with ... with P_m { D_1; ...; D_n} RefinedType(List(P_1, ..., P_m), Scope(D_1, ..., D_n)) P_1 with ... with P_m RefinedType(List(P_1, ..., P_m), Scope()) { D_1; ...; D_n} RefinedType(List(AnyRef), Scope(D_1, ..., D_n))
The API that all refined types support. The main source of information about types is the scala.reflect.api.Types page.
An extractor class to create and pattern match with syntax RefinedType(parents, decls)
Here, parents
is the list of parent types of the class, and decls
is the scope containing all declarations in the class.
The SingleType
type describes types of any of the forms on the left, with their TypeRef representations to the right.
(T # x).type SingleType(T, x) p.x.type SingleType(p.type, x) x.type SingleType(NoPrefix, x)
The API that all single types support. The main source of information about types is the scala.reflect.api.Types page.
An extractor class to create and pattern match with syntax SingleType(pre, sym)
Here, pre
is the prefix of the single-type, and sym
is the stable value symbol referred to by the single-type.
The type of Scala singleton types, i.e., types that are inhabited by only one nun-null value. These include types of the forms
C.this.type C.super.type x.type
as well as constant types.
Has no special methods. Is here to provides erased identity for SingletonType
.
The SuperType
type is not directly written, but arises when C.super
is used as a prefix in a TypeRef
or SingleType
. Its internal presentation is
SuperType(thistpe, supertpe)
Here, thistpe
is the type of the corresponding this-type. For instance, in the type arising from C.super, the thistpe
part would be ThisType(C)
. supertpe
is the type of the super class referred to by the super
.
The API that all super types support. The main source of information about types is the scala.reflect.api.Types page.
An extractor class to create and pattern match with syntax SuperType(thistpe, supertpe)
A singleton type that describes types of the form on the left with the corresponding ThisType
representation to the right:
C.this.type ThisType(C)
The API that all this types support. The main source of information about types is the scala.reflect.api.Types page.
An extractor class to create and pattern match with syntax ThisType(sym)
where sym
is the class prefix of the this type.
The type of Scala types, and also Scala type signatures. (No difference is internally made between the two).
The API of types. The main source of information about types is the scala.reflect.api.Types page.
The TypeBounds
type signature is used to indicate lower and upper type bounds of type parameters and abstract types. It is not a first-class type. If an abstract type or type parameter is declared with any of the forms on the left, its type signature is the TypeBounds type on the right.
T >: L <: U TypeBounds(L, U) T >: L TypeBounds(L, Any) T <: U TypeBounds(Nothing, U)
The API that all type bounds support. The main source of information about types is the scala.reflect.api.Types page.
An extractor class to create and pattern match with syntax TypeBound(lower, upper)
Here, lower
is the lower bound of the TypeBounds
pair, and upper
is the upper bound.
The TypeRef
type describes types of any of the forms on the left, with their TypeRef representations to the right.
T # C[T_1, ..., T_n] TypeRef(T, C, List(T_1, ..., T_n)) p.C[T_1, ..., T_n] TypeRef(p.type, C, List(T_1, ..., T_n)) C[T_1, ..., T_n] TypeRef(NoPrefix, C, List(T_1, ..., T_n)) T # C TypeRef(T, C, Nil) p.C TypeRef(p.type, C, Nil) C TypeRef(NoPrefix, C, Nil)
The API that all type refs support. The main source of information about types is the scala.reflect.api.Types page.
An extractor class to create and pattern match with syntax TypeRef(pre, sym, args)
Here, pre
is the prefix of the type reference, sym
is the symbol referred to by the type reference, and args
is a possible empty list of type arguments.
The constructor/extractor for Alternative
instances.
The constructor/extractor for Annotated
instances.
The constructor/extractor for AnnotatedType
instances.
The constructor/extractor for Annotation
instances.
The constructor/extractor for AppliedTypeTree
instances.
The constructor/extractor for Apply
instances.
The constructor/extractor for Assign
instances.
The constructor/extractor for Bind
instances.
The constructor/extractor for Block
instances.
The constructor/extractor for BoundedWildcardType
instances.
The constructor/extractor for CaseDef
instances.
The constructor/extractor for ClassDef
instances.
The constructor/extractor for ClassInfoType
instances.
The constructor/extractor for CompoundTypeTree
instances.
The constructor/extractor for Constant
instances.
The constructor/extractor for ConstantType
instances.
The constructor/extractor for DefDef
instances.
The empty tree
The constructor/extractor for ExistentialType
instances.
The constructor/extractor for ExistentialTypeTree
instances.
A module that contains all possible values that can constitute flag sets.
Tag that preserves the identity of FreeTermSymbol
in the face of erasure. Can be used for pattern matching, instance tests, serialization and the like.
Tag that preserves the identity of FreeTermSymbol
in the face of erasure. Can be used for pattern matching, instance tests, serialization and the like.
The constructor/extractor for Function
instances.
A factory method for Ident
nodes.
The constructor/extractor for Ident
instances.
The constructor/extractor for If
instances.
The constructor/extractor for Import
instances.
The constructor/extractor for ImportSelector
instances.
The constructor/extractor for LabelDef
instances.
The constructor/extractor for Literal
instances.
The constructor/extractor for Match
instances.
The constructor/extractor for MethodType
instances.
The constructor/extractor for Modifiers
instances.
The constructor/extractor for ModuleDef
instances.
The constructor/extractor for NamedArg
instances.
The constructor/extractor for New
instances.
The empty set of flags
A special "missing" position.
This constant is used as a special value denoting the empty prefix in a path dependent type. For instance x.type
is represented as SingleType(NoPrefix, <x>)
, where <x>
stands for the symbol for x
.
A special "missing" symbol. Commonly used in the API to denote a default or empty value.
This constant is used as a special value that indicates that no meaningful type exists.
The constructor/extractor for NullaryMethodType
instances.
The constructor/extractor for PackageDef
instances.
The constructor/extractor for PolyType
instances.
The constructor/extractor for RefTree
instances.
The constructor/extractor for ReferenceToBoxed
instances.
Tag that preserves the identity of ReferenceToBoxed
in the face of erasure. Can be used for pattern matching, instance tests, serialization and the like.
The constructor/extractor for RefinedType
instances.
The constructor/extractor for Return
instances.
A factory method for Select
nodes.
The constructor/extractor for Select
instances.
The constructor/extractor for SelectFromTypeTree
instances.
The constructor/extractor for SingleType
instances.
The constructor/extractor for SingletonTypeTree
instances.
The constructor/extractor for Star
instances.
The constructor/extractor for Super
instances.
The constructor/extractor for SuperType
instances.
The constructor/extractor for Template
instances.
The constructor/extractor for TermName
instances.
A factory method for This
nodes.
The constructor/extractor for This
instances.
The constructor/extractor for ThisType
instances.
The constructor/extractor for Throw
instances.
The constructor/extractor for Try
instances.
The constructor/extractor for TypeApply
instances.
The constructor/extractor for TypeBounds
instances.
The constructor/extractor for TypeBoundsTree
instances.
The constructor/extractor for TypeDef
instances.
The constructor/extractor for TypeName
instances.
The constructor/extractor for TypeRef
instances.
A factory method for TypeTree
nodes.
The constructor/extractor for TypeTree
instances.
The constructor/extractor for Typed
instances.
The constructor/extractor for UnApply
instances.
The constructor/extractor for ValDef
instances.
An object representing an unknown type, used during type inference. If you see WildcardType outside of inference it is almost certainly a bug.
The API of FlagSet
instances.
A creator for type applications.
Useful to combine and create types out of generic ones. For example:
scala> val boolType = typeOf[Boolean] boolType: reflect.runtime.universe.Type = Boolean scala> val optionType = typeOf[Option[_]] optionType: reflect.runtime.universe.Type = Option[_] scala> appliedType(optionType.typeConstructor, boolType) res0: reflect.runtime.universe.Type = Option[Boolean]
Assigns a given position to all position-less nodes of a given AST.
A value containing all standard definitions in DefinitionsApi
The greatest lower bound of a list of types, as determined by <:<
.
The least upper bound of a list of types, as determined by <:<
.
Hook to define what showCode(...)
means.
Creates a lazy tree copier.
Hook to define what showRaw(...)
means.
Creates a strict tree copier.
Hook to define what show(...)
means.
An empty deferred value definition corresponding to: val _: _ This is used as a placeholder in the self
parameter Template if there is no definition of a self value of self type.
An empty superclass constructor call corresponding to: super.<init>() This is used as a placeholder in the primary constructor body in class templates to denote the insertion point of a call to superclass constructor after the typechecker figures out the superclass of a given template.
The root mirror of this universe. This mirror contains standard Scala classes and types such as Any
, AnyRef
, AnyVal
, Nothing
, Null
, and all classes loaded from scala-library, which are shared across all mirrors within the enclosing universe.
Creates a runtime reflection mirror from a JVM classloader.
For more information about Mirrors
s, see scala.reflect.api.Mirrors or the Reflection Guide: Mirrors
Renders a prettified representation of a position.
Renders a prettified representation of a flag set.
Renders a prettified representation of a name.
Renders a string that represents a declaration of this symbol written in Scala.
Type symbol of x
as derived from a type tag.
A value containing all standard term names.
A value containing all standard type names.
A position that wraps the non-empty set of trees. The point of the wrapping position is the point of the first trees' position. If all some the trees are non-synthetic, returns a range position enclosing the non-synthetic trees Otherwise returns a synthetic offset position to point.
A position that wraps a set of trees. The point of the wrapping position is the point of the default position. If some of the trees are ranges, returns a range position enclosing all ranges Otherwise returns default position.
A factory method for Apply
nodes.
(Since version 2.10.1) use q"$sym(..$args)" instead
0-1 argument list new, based on a type tree.
(Since version 2.10.1) use q"new $tpt(..$args)" instead
A factory method for Bind
nodes.
(Since version 2.10.1) use the canonical Bind constructor to create a bind and then initialize its symbol manually
A factory method for Block
nodes. Flattens directly nested blocks.
(Since version 2.10.1) use q"{..$stats}" instead. Flatten directly nested blocks manually if needed
A factory method for CaseDef
nodes.
(Since version 2.10.1) use cq"$pat => $body" instead
A factory method for Ident
nodes.
(Since version 2.10.1) use Ident(TermName(name)) instead
0-1 argument list new, based on a symbol.
(Since version 2.10.1) use q"new ${sym.toType}(..$args)" instead
0-1 argument list new, based on a type.
(Since version 2.10.1) use q"new $tpe(..$args)" instead
Factory method for object creation new tpt(args_1)...(args_n)
A New(t, as)
is expanded to: (new t).<init>(as)
(Since version 2.10.1) use q"new $tpt(...$argss)" instead
A factory method for Select
nodes. The string name
argument is assumed to represent a TermName
.
(Since version 2.10.1) use Select(tree, TermName(name)) instead
A factory method for Super
nodes.
(Since version 2.10.1) use q"$sym.super[$mix].x".qualifier instead
A factory method for Throw
nodes.
(Since version 2.10.1) use q"throw new $tpe(..$args)" instead
A factory method for Try
nodes.
(Since version 2.10.1) convert cases into casedefs and use q"try $body catch { case ..$newcases }" instead
Provides enrichments to ensure source compatibility between Scala 2.10 and Scala 2.11. If in your reflective program for Scala 2.10 you've used something that's now become an internal API, a single compat._
import will fix things for you.
(Since version 2.13.0) compatibility with Scala 2.10 EOL
(Since version 2.11.0) use noSelfType
instead
Create a new term name.
(Since version 2.11.0) use TermName instead
Creates a new type name.
(Since version 2.11.0) use TypeName instead
(Since version 2.11.0) use termNames
instead
(Since version 2.11.0) use typeNames
instead
Constructor/Extractor for Expr.
Can be useful, when having a tree and wanting to splice it in reify call, in which case the tree first needs to be wrapped in an expr.
The main source of information about exprs is the scala.reflect.api.Exprs page.
The factory for Modifiers
instances.
The factory for Modifiers
instances.
An empty Modifiers
object: no flags, empty visibility annotation and no Scala annotations.
Delegates the transformation strategy to scala.reflect.internal.Trees
, because pattern matching on abstract types we have here degrades performance.
Use reify
to produce the abstract syntax tree representing a given Scala expression.
For example:
val five = reify{ 5 } // Literal(Constant(5)) reify{ 5.toString } // Apply(Select(Literal(Constant(5)), TermName("toString")), List()) reify{ five.splice.toString } // Apply(Select(five, TermName("toString")), List())
The produced tree is path dependent on the Universe reify
was called from.
Use scala.reflect.api.Exprs#Expr.splice to embed an existing expression into a reify
call. Use Expr to turn a Tree into an expression that can be spliced.
Renders a representation of a reflection artifact as desugared Scala code.
Renders the code of the passed tree, so that: 1) it can be later compiled by scalac retaining the same meaning, 2) it looks pretty. #1 is available for unattributed trees and attributed trees #2 is more or less okay indentation-wise, but at the moment there's a lot of desugaring left in place, and that's what we plan to improve in the future. printTypes, printIds, printPositions options have the same meaning as for TreePrinter printRootPkg option is available only for attributed trees.
Renders internal structure of a position.
Renders internal structure of a flag set.
Renders internal structure of a name.
Renders internal structure of a reflection artifact as the visualization of a Scala syntax tree.
The standard (lazy) tree copier.
By default trees are printed with show
Shortcut for implicitly[TypeTag[T]].tpe
Shortcut for implicitly[TypeTag[T]]
Shortcut for implicitly[WeakTypeTag[T]].tpe
Shortcut for implicitly[WeakTypeTag[T]]
Provides an extension hook for the transformation strategy. Future-proofs against new node types.
Companion to Liftable
type class that contains standard instances and provides a helper apply
method to simplify creation of new ones.
Companion to Unliftable
type class that contains standard instances and provides a helper apply
method to simplify creation of new ones.
Type tags corresponding to primitive types and constructor/extractor for WeakTypeTags.
Type tags corresponding to primitive types and constructor/extractor for WeakTypeTags.
© 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/JavaUniverse.html
EXPERIMENTAL
A refinement of scala.reflect.api.Universe for runtime reflection using JVM classloaders.
This refinement equips mirrors with reflection capabilities for the JVM.
JavaMirror
can convert Scala reflection artifacts (symbols and types) into Java reflection artifacts (classes) and vice versa. It can also perform reflective invocations (getting/setting field values, calling methods, etc).See the Reflection Guide for details on how to use runtime reflection.