Creates a new mirror which uses the same symbol, but is bound to a different receiver. This is significantly faster than recreating the mirror from scratch.
Retrieves the value stored in the field.
Scala reflection uses reflection capabilities of the underlying platform, so FieldMirror.get
might throw platform-specific exceptions associated with getting a field or invoking a getter method of the field.
If symbol
represents a field of a base class with respect to the class of the receiver, and this base field is overridden in the class of the receiver, then this method will retrieve the value of the base field. To achieve overriding behavior, use reflectMethod on an accessor.
Updates the value stored in the field.
If a field is immutable, a ScalaReflectionException
will be thrown.
Scala reflection uses reflection capabilities of the underlying platform, so FieldMirror.get
might throw platform-specific exceptions associated with setting a field or invoking a setter method of the field.
If symbol
represents a field of a base class with respect to the class of the receiver, and this base field is overridden in the class of the receiver, then this method will set the value of the base field. To achieve overriding behavior, use reflectMethod on an accessor.
The field symbol representing the field.
In Scala val
and var
declarations are usually compiled down to a pair of a backing field and corresponding accessor/accessors, which means that a single declaration might correspond to up to three different symbols. Nevertheless the FieldMirror.symbol
field always points to a backing field symbol.
© 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/Mirrors$FieldMirror.html
A mirror that reflects a field. See the overview page for details on how to use runtime reflection.