Lookup.unreflectSetter/unreflectGetter and volatile fields
Remi Forax
forax at univ-mlv.fr
Sun Jun 16 11:03:08 UTC 2019
Hi Kasper,
as usual, a getter on a volatile field will return a method handle that does a volatile read.
The idea of the basic methodhandles, the one for field access, method calls, etc is to have exactly the same semantics as the bytecode equivalent, so unreflectGetter works like getfield and unreflectSetter like putfield.
If you want a different semantics, you can use the VarHandles.
regards,
Rémi
----- Mail original -----
> De: "Kasper Nielsen" <kasperni at gmail.com>
> À: "core-libs-dev" <core-libs-dev at openjdk.java.net>
> Envoyé: Dimanche 16 Juin 2019 12:16:24
> Objet: Lookup.unreflectSetter/unreflectGetter and volatile fields
> Hi,
>
> Can anyone tell me how Lookup.unreflectSetter(Field) and
> Lookup.unreflectGetter(Field) works with volatile fields.
> Nothing is mentioned in the Javadoc of the methods. And by looking at
> the code for Lookup I couldn't really get a clearer picture.
>
> Thanks
> Kasper
More information about the core-libs-dev
mailing list