[concurrency-interest] Joda-Time immutability

Gregg Wonderly gregg at cytetech.com
Tue Jun 21 09:17:45 EDT 2011

On 6/21/2011 6:49 AM, Stephen Colebourne wrote:
> On 21 June 2011 09:11, Mark Thornton<mthornton at optrak.com>  wrote:
>> This should be backward compatible with existing serialized instances while
>> allowing the fields in BaseDateTime to be final. It comes at the expense of
>> a slightly larger MutableDateTime object, and slightly slower
>> deserialization.
> In the end, I think Doug's advice is probably right. Just use
> volatile. I don't think its ideal, but it "Just Works", which is a
> good thing in this codebase.
> Mark, I think your change would work (and I like the neat set before
> defaultReadFields). However it would have required any mutable
> application subclass to be changed, which I was hoping to avoid.

This is one of the things about property pattern uses in Java that really 
creates problems for a lot of people.  It would be nice if field references 
would automatically translate to getter and setter calls when those methods are 
present in the class.  That would really help super class maintenance issues 
such as these be much easier to manage.

In some sense, there is also the argument that if you really want a property to 
be "public" then it should be accessed via getter/setter methods always.

Gregg Wonderly

More information about the Concurrency-interest mailing list