Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6471768
Votes 1
Synopsis (coll) Checked Collections to implement interface to expose the checked type
Category java:classes_util
Reported Against
Release Fixed
State 5-Cause Known, request for enhancement
Priority: 5-Very Low
Related Bugs
Submit Date 18-SEP-2006
Description
A DESCRIPTION OF THE REQUEST :
It would be helpful if the checkedCollection implementations from java.util.Collections (including checkedList, checkedSet, checkedSortedSet) implemented an interface that allowed the checked type to be retrieved. Something like:

interface CheckedCollection<E> {
    Class<E> getType();
}

and something similar for the keyType and valueType of Maps.


JUSTIFICATION :
The existing checked collections provide a way of enforcing run-time restrictions of the type of elements added to collections, but no way to discover what the checked-type of a collection actually is.

In dynamicly evaluated expressions (such as the javaee5 unified expression language), you often want to convert a string value in to a specific type (perhaps via a java.beans.PropertyEditor) so that it can be added to a collection. Currently there is no convenient way to know the type that the string should be converted to.

In addition, this would allow a safe dynamic casting of collections in some situations, as perhaps intended by the RFE at
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6351592
(which itself was not an adequate solution).
If the source collection is already of the requested type, it could be returned directly, otherwise a new checked collection could be created. Without the suggested interface, a new collection would be needed every time.

Finally, any user collection classes that implement type checking could also implement this interface, making it more general than testing for the specific class that java.util.Collections.checkedCollection may return.
Posted Date : 2006-09-18 08:49:44.0
Work Around
N/A
Evaluation
An reasonable suggestion.
Posted Date : 2006-09-18 09:13:27.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang