Udostępnij za pośrednictwem


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

Definition

Produces a VarHandle giving access to a static field name of type type declared in a class of type decl.

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

Parameters

decl
Class

the class that declares the static field

name
String

the field's name

type
Class

the field's type, of type T

Returns

a VarHandle giving access to a static field

Attributes

Remarks

Produces a VarHandle giving access to a static field name of type type declared in a class of type decl. The VarHandle's variable type is type and it has no coordinate types.

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

If the returned VarHandle is operated on, the declaring class will be initialized, if it has not already been initialized.

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.findStaticVarHandle(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