|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
A DESCRIPTION OF THE REQUEST :
I'm not sure if this is against the spec, but it's certainly annoying...
The following code snippet returns HashMap$KeySet, which is a subclass of AbstractSet, and thus not Serializable.The parent HashMap object is Serializable though.
{
Set set = map.keySet();
}
JUSTIFICATION :
Main use case for this is if one wants to store a keySet in a J2EE HttpSession - I could store the HashMap, so why can't I store it's keySet()?
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
HashMap$KeySet implements Serializable
ACTUAL -
HashMap$KeySet extends AbstractSet
(and doesn't implement Serializable)
---------- BEGIN SOURCE ----------
See above - no other need for code example
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
new HashSet( map.keySet() );
Obviously this isn't a good example for performance / efficiency.
|