Re: JavaMemoryModel: Idiom for safe, unsynchronized reads

From: Doug Lea (dl@altair.cs.oswego.edu)
Date: Mon Jun 28 1999 - 10:38:09 EDT


One minor amplification on one of Josh's points: The current model
already makes a promise about initial object states (i.e., all-zeros),
so some kind of protection is already needed. The mistake was not
extending this promise to any plausible OO account of construction,
which entails field initialization. Unfortunately, Java initialization
semantics are messy and loose, so it is tricky to graft this on. Life
would arguably have been better if java required constructors to ONLY
initialize fields, with no additional side effects; thus avoiding all
the shoot-yourself-in-the-foot problems. (In CPJ/2e, I strongly urge
people to use constructors solely for field initialization, in order
to avoid encountering these problems in the first place.)

-- 
Doug Lea, Computer Science Department, SUNY Oswego, Oswego, NY 13126 USA
dl@cs.oswego.edu 315-341-2688 FAX:315-341-5424 http://gee.cs.oswego.edu/  
-------------------------------
This is the JavaMemoryModel mailing list, managed by Majordomo 1.94.4.

To send a message to the list, email JavaMemoryModel@cs.umd.edu To send a request to the list, email majordomo@cs.umd.edu and put your request in the body of the message (use the request "help" for help). For more information, visit http://www.cs.umd.edu/~pugh/java/memoryModel



This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:13 EDT