ShenandoahOptimizeFinals is an illegal optimization

Roland Westrelin rwestrel at redhat.com
Wed Oct 18 13:35:26 UTC 2017


> I think the failure mechanisms are different, but the phenomenon is the same: whether you can trust
> final field values, and thus get exposed to "old" values -- which is formally allowed by spec. The
> way you trust those fields, either via compiler optimizations that constant-fold "old" values, or
> GC-specific optimization that exposes "old" values to users is not very relevant here, I think.

What you're saying is that code like:

    private final List<Provider> userList = new AbstractList<Provider>() {
        public int size() {
            return configs.length;
        }
        public Provider get(int index) {
            return getProvider(index);
        }
    };

that initializes a field with a just allocated instance of an inner
class is inherently broken?

Roland.


More information about the shenandoah-dev mailing list