[cp-patches] RFC: Fix for PR27128

Olivier Jolly olivier.jolly at pcedev.com
Sun Apr 23 17:21:27 UTC 2006


Hi,
  this patch makes sure that the UnmodifiableMap.entrySet() result can't 
be used to change the wrapped map using toArray() or toArray(Object[]). 
It does so by recreating a resulting array using UnmodifiableMapEntry, 
which has been extracted from the inner class used as return value in 
the iterator method of UnmodifableEntrySet.
  However, I find this solution quite bulky and inelegant. If anyone is 
thinking of a cleaner way, please shout on me.
  Cheers
+Olivier

2006-04-23  Olivier Jolly  <olivier.jolly at pcedev.com>

  * java/util/Collections.java(UnmodifiableMap.UnmodifiableEntrySet.
  UnmodifiableMapEntry): New Map.Entry implementation which is immutable.
  (UnmodifiableMap.UnmodifiableEntrySet.iterator,
  UnmodifiableMap.UnmodifiableEntrySet.toArray,
  UnmodifiableMap.UnmodifiableEntrySet.toArray(Object[])): Used 
UnmodifiableMapEntry
  as part of their return value.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: unmodifiableEntrySet.patch
Type: text/x-patch
Size: 6074 bytes
Desc: not available
Url : http://developer.classpath.org/pipermail/classpath-patches/attachments/20060423/af5e494a/unmodifiableEntrySet.bin


More information about the Classpath-patches mailing list