XStream
  1. XStream
  2. XSTR-218

Arrays.asList fails - bug or impossible?

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: None
    • Fix Version/s: 1.1.3
    • Component/s: None
    • Labels:
      None
    • JDK version and platform:
      jdk 1.5_03 on Windows

      Description

      I'm new to XStream (tried to use it with mule) and while doing my first experiment I of course stepped on a mine. Looky:

      XStream xstream = new XStream();
      Object o = Arrays.asList(new Integer[]

      {new Integer(42)}

      );
      String xml = xstream.toXML(o);
      log.info("xml: " + xml);
      Object newObject = xstream.fromXML(xml);
      log.info("new object: " + newObject);

      gives:

      [05-10 22:27:10] INFO XStreamTest: xml: <java.util.Arrays-ArrayList>
      <a class="int-array">
      <int>42</int>
      </a>
      </java.util.Arrays-ArrayList>
      Exception in thread "main" java.lang.NullPointerException
      at java.lang.String.valueOf(Unknown Source)
      at java.util.AbstractCollection.toString(Unknown Source)
      at java.lang.String.valueOf(Unknown Source)
      at java.lang.StringBuffer.append(Unknown Source)
      at h2o.playground.XStreamTest.main(XStreamTest.java:24)

      It seems XStream has problems properly recognizing the static inner class in java.util.Arrays which is a special kind of ArrayList that doesn't copy the array it contains.
      From reading the feature list I'm not sure if this is a bug in XStream; if I need to configure something in a special way or this is just a special case that does not work, please let me know and disregard this bug.
      Thanks,
      Holger

        People

        • Assignee:
          Unassigned
          Reporter:
          Holger Hoffstätte
        • Votes:
          0 Vote for this issue
          Watchers:
          1 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: