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" <kaspe...@gmail.com> > À: "core-libs-dev" <core-libs-dev@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