[jmm-dev] ECOOP, JVMLS

Hans Boehm boehm at acm.org
Wed Aug 6 18:12:00 UTC 2014


On Wed, Aug 6, 2014 at 9:04 AM, Doug Lea <dl at cs.oswego.edu> wrote:

> ...
>
> Here, I'm not sure who would be surprised that if a constructor
> accesses non-local state, then without care, there are few/weak
> reader-side guarantees.


But this is often hidden behind abstraction boundaries, right?

If x has a logical field F, accessed with a getter and set in its
constructor, then if I write

tmp = x;  // racy read
if (tmp != null) myF = x.getF();

will work if F is implemented as an actual field, but break if it's
implemented via IdentityHashMap.  Thus the correctness of this sort of
stuff depends on what used to be implementation details.  We're effectively
widening class interfaces.  There will be even more stuff that needs to be
documented about interfaces, but never is.

That problem already exists to some extent with final fields, but it seems
to me like we'd be confusing the issue further.


More information about the jmm-dev mailing list