[jmm-dev] The JSR-133 Cookbook and final fields

Andrew Haley aph at redhat.com
Mon Nov 21 15:32:12 UTC 2016


On 21/11/16 13:24, Doug Lea wrote:
> In any case, I'm not sure we can/should decode JSR133 specs that we
> know need fixing. For now, it seems that the most useful guarantee we
> can make is the operational spec that any class with a final field
> contains a storeStoreFence before/upon constructor return. As with
> other VarHandle documentation, this is sometimes not enough, but the
> best we have at the moment.

We're working on this right now in Graal.  If an object does not
escape, is it legitimate to remove the StoreStore fence as well?  I
think it is, but it means that we have to treat

class X1 {
    final int x;

    X1() {
    }
}

and

class X1 {
    int x;

    X1() {
        VarHandle.storeStoreFence();
    }
}

differently.

Andrew.


More information about the jmm-dev mailing list