Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5095896

(coll) Arrays.asList should return something Serializable

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 1.4.2
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description



      Name: js151677 Date: 09/02/2004


      A DESCRIPTION OF THE REQUEST:
      Arrays.asList returns java.util.List - however the *internal* class ArrayList implements Serializable which List does not. Therefore using the result of asList where Serializable is required is not possible (does not compile).

          public static List asList(Object[] a) {
      return new ArrayList(a);
          }

          /**
           * @serial include
           */
          private static class ArrayList extends AbstractList
      implements RandomAccess, java.io.Serializable


      JUSTIFICATION :
      It better reflects reality

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Unfortunately i don't see a public class that has the requirements of the internal ArrayList. I guess the only solution would be to make the private static class ArrayList public.

      CUSTOMER SUBMITTED WORKAROUND :
      I don't find any of the collections that takes an array in the constructor or as an argument to, say, addAll(). This makes for uglier-than-necessary code.
      (Incident Review ID: 301515)
      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              smarks Stuart Marks
              Reporter:
              jssunw Jitender S (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: