Lookup.unreflectSetter/unreflectGetter and volatile fields

Kasper Nielsen kasperni at gmail.com
Sun Jun 16 15:08:36 UTC 2019


Hi Remi,

Thanks, that was what I assumed as well. It was only because
Lookup.unreflectVarHandle() was very particular about every possible
modifier type. That I had a second of doubt.

Best,
  Kasper

On Sun, 16 Jun 2019 at 12:03, Remi Forax <forax at univ-mlv.fr> wrote:
>
> 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