次の方法で共有


MethodHandles.Lookup.FindVarHandle(Class, String, Class) Method

Definition

Produces a VarHandle giving access to a non-static field name of type type declared in a class of type recv.

[Android.Runtime.Register("findVarHandle", "(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/invoke/VarHandle;", "", ApiSince=33)]
public Java.Lang.Invoke.VarHandle FindVarHandle (Java.Lang.Class recv, string name, Java.Lang.Class type);
[<Android.Runtime.Register("findVarHandle", "(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/invoke/VarHandle;", "", ApiSince=33)>]
member this.FindVarHandle : Java.Lang.Class * string * Java.Lang.Class -> Java.Lang.Invoke.VarHandle

Parameters

recv
Class

the receiver class, of type R, that declares the non-static field

name
String

the field's name

type
Class

the field's type, of type T

Returns

a VarHandle giving access to non-static fields.

Attributes

Remarks

Produces a VarHandle giving access to a non-static field name of type type declared in a class of type recv. The VarHandle's variable type is type and it has one coordinate type, recv.

Access checking is performed immediately on behalf of the lookup class.

Certain access modes of the returned VarHandle are unsupported under the following conditions: <ul> <li>if the field is declared final, then the write, atomic update, numeric atomic update, and bitwise atomic update access modes are unsupported. <li>if the field type is anything other than byte, short, char, int, long, float, or double then numeric atomic update access modes are unsupported. <li>if the field type is anything other than boolean, byte, short, char, int or long then bitwise atomic update access modes are unsupported. </ul>

If the field is declared volatile then the returned VarHandle will override access to the field (effectively ignore the volatile declaration) in accordance to its specified access modes.

If the field type is float or double then numeric and atomic update access modes compare values using their bitwise representation (see Float#floatToRawIntBits and Double#doubleToRawLongBits, respectively).

Added in 9.

Java documentation for java.lang.invoke.MethodHandles.Lookup.findVarHandle(java.lang.Class<?>, java.lang.String, java.lang.Class<?>).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to