On 16/09/2016 14:07, Mungo Carstairs (Staff) wrote:
> I fell to wondering why Java doesn't provide things like a 'read-only'
> view of a collection...thinks...you could wrap a List with a List
> that overrides all update methods to throw an exception...Googled for
> this...well well it is already there...
I really ought to read my mail before googling to resolve niggling
I reached the same conclusion and put a patch together:
Its not merged in because a few tests fail - but may be a better
solution (and may also prove useful for the AnnotatedCollectionI
containers, too !)
> I'm just very surprised it doesn't get a mention in Effective Java Item
> 39, which discusses defensive copying, and that it's not more widely
> known (at least I've never come across it being used).
I suspect it slipped through because the Collections API was not
released until after the first edition, and there were other priorities
for the second edition. Maybe its time for a review !
Jalview-dev mailing list