[concurrency-interest] Joda-Time immutability

Stephen Colebourne scolebourne at joda.org
Mon Jun 20 10:33:17 EDT 2011


On 20 June 2011 15:23, Mark Thornton <mthornton at optrak.com> wrote:
> On 20/06/11 15:03, Stephen Colebourne wrote:
>>
>> The "reflection can set final fields" comment was directed at
>> serialization, but has actually provided a reasonably acceptable
>> solution (thanks Mark).
>>
>> Basically, I've made the fields final, and changed the setters to use
>> reflection (breaking the final restriction). Since 99% of use cases
>> are immutable, this will only impact the mutable users (a little bit
>> slower), and they should really move to the immutable classes
>> anyway...
>>
> A potential catch with using reflection is when a SecurityManager is in use.

Agreed, but users can move to the immutable classes to avoid reflection.

Its a least worst option choice for a version 2.0.

Stephen


More information about the Concurrency-interest mailing list