Hi Martin,

This makes total sense to me, and allows to take advantage of downstream 
flexibility where we simply
want to standardize on interfaces like Lists and Collections.

Cheers,
Chris

On Oct 11, 2012, at 8:47 AM, Martin Desruisseaux wrote:

> Hello all
> 
> The last commit added CheckedArrayList, CheckedHashSet and CheckedHashMap, 
> which extend the standard JDK classes with the addition of synchronization, 
> runtime type checks and write permission checks. Usually, the synchronization 
> and type checks are provided in the standard JDK by the following methods:
> 
>  * Collections.synchronizedSet(Set)
>  * Collections.checkedSet(Set, Class)
> 
> However the standard synchronizedSet(Set) method does not allow us to specify 
> a lock different than 'this'. In the metadata implementation, we wanted to 
> synchronize on the metadata object that own the collection rather than the 
> collection itself.
> 
> The check for write permission is a little bit different than the standard 
> Collections.unmodifiableSet(Set) method, in that it is determined by a 
> condition external to the collection itself: in our case, it is determined by 
> whether the metadata which own the collection has been made "read only".
> 
> By extending directly the ArrayList, LinkedHashSet and LinkedHashMap classes 
> instead than creating wrappers around arbitrary List, Set and Map, we avoid 
> the indirection levels of Collections.synchronizedSet wrapping 
> Collections.checkedSet wrapping LinkedHashSet for instance. Those 3 
> particular implementations are used very often, so I though that they were 
> worth special treatment. When we really need wrappers around arbitrary 
> implementations, the standard java.util.Collections methods are perfect for 
> that.
> 
> The base class of metadata objects has been updated for using those checked 
> collections. So things are slowly starting to fall in place.
> 
>    Martin
> 

Reply via email to