JDK-4782922 : ArrayList.subList() does not return a serializable object
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util:collections
  • Affected Version: 1.4.0,5.0,6u10
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic,solaris_8,windows_xp
  • CPU: generic,x86,sparc
  • Submitted: 2002-11-21
  • Updated: 2021-03-03
  • Resolved: 2002-12-10
Related Reports
Duplicate :  
Relates :  
Description

Name: rmT116609			Date: 11/21/2002


DESCRIPTION OF THE PROBLEM :
subList() of array list return an non serializable object. It causes us problems when we tried to pass a sub list of array list to an ejb session bean method. By studying the source code of JDK, we found that return object is of an
internal class called SubList which extends AbstractList. And AbstractList does not implement serializable.

EXPECTED VERSUS ACTUAL BEHAVIOR :
I understand we can have a workround for this simply new an new array list. However, I believe JDK should perserve the serializblablity by checking it and return it accordingly.

CUSTOMER WORKAROUND :
new an array list of the result of subList()
(Review ID: 166754) 
======================================================================

Comments
EVALUATION This was intentional, and is entirely appropriate for "views." If you serialize a small view (say three elements), the entire backing List (say one million elements) gets serialized. If you deserilize the view, the entire million element list gets reconstructed at great cost, even though 99.9967% of it is forever inacessible. ###@###.### 2002-12-09
09-12-2002