jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • XStream
  • XSTR-218

Arrays.asList fails - bug or impossible?

  • Log In
  • Views
    • XML
    • Word
    • Printable

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

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • History
  • Activity
Hide
Permalink
Holger Hoffstätte added a comment - 10/May/05 4:36 PM

Some more info. It turns out that the object is re-created properly, but for some reason toString() fails. I suspected that it's related to my using eclipse 3.0.2 in 1.4-mode with jdk 1.5 but that doesn't seem to be the case; it happens when compiled from the command line, too.
Interestingly enough, the following:

List newObject = (List)xstream.fromXML(xml);
log.info("new.size: " + newObject.size());
log.info("new(0):" + newObject.get(0));

gives:

INFO: new.size: 1
Exception in thread "main" java.lang.NullPointerException
at java.lang.String.valueOf(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at h2o.playground.XStreamTest.main(XStreamTest.java:28)

so it seems the problen is the List's internal array. It gets better though:

Object first = newObject.get(0);
log.info("first.class:" + first.getClass());

gives the best fireworks:

INFO: new.size: 1
#

  1. An unexpected error has been detected by HotSpot Virtual Machine:
    #
  2. EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d701051, pid=3176, tid=1816
    #
  3. Java VM: Java HotSpot(TM) Client VM (1.5.0_03-b07 mixed mode, sharing)
  4. Problematic frame:
  5. V [jvm.dll+0xc1051]
    #
  6. An error report file with more information is saved as hs_err_pid3176.log
    #
  7. If you would like to submit a bug report, please visit:
  8. http://java.sun.com/webapps/bugreport/crash.jsp
    #

..which indicates that the internal array is not null and contains something really bogus. I didn't investigate the stack trace further

Show
Holger Hoffstätte added a comment - 10/May/05 4:36 PM Some more info. It turns out that the object is re-created properly, but for some reason toString() fails. I suspected that it's related to my using eclipse 3.0.2 in 1.4-mode with jdk 1.5 but that doesn't seem to be the case; it happens when compiled from the command line, too. Interestingly enough, the following: List newObject = (List)xstream.fromXML(xml); log.info("new.size: " + newObject.size()); log.info("new(0):" + newObject.get(0)); gives: INFO: new.size: 1 Exception in thread "main" java.lang.NullPointerException at java.lang.String.valueOf(Unknown Source) at java.lang.StringBuilder.append(Unknown Source) at h2o.playground.XStreamTest.main(XStreamTest.java:28) so it seems the problen is the List's internal array. It gets better though: Object first = newObject.get(0); log.info("first.class:" + first.getClass()); gives the best fireworks: INFO: new.size: 1 #
  1. An unexpected error has been detected by HotSpot Virtual Machine: #
  2. EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d701051, pid=3176, tid=1816 #
  3. Java VM: Java HotSpot(TM) Client VM (1.5.0_03-b07 mixed mode, sharing)
  4. Problematic frame:
  5. V [jvm.dll+0xc1051] #
  6. An error report file with more information is saved as hs_err_pid3176.log #
  7. If you would like to submit a bug report, please visit:
  8. http://java.sun.com/webapps/bugreport/crash.jsp #
..which indicates that the internal array is not null and contains something really bogus. I didn't investigate the stack trace further
Hide
Permalink
Holger Hoffstätte added a comment - 18/Jul/05 5:29 AM

Apparently this was a VM bug in 1.5_03; it doesn't happen any longer in 1.5_04 - everything works as expected now.

Show
Holger Hoffstätte added a comment - 18/Jul/05 5:29 AM Apparently this was a VM bug in 1.5_03; it doesn't happen any longer in 1.5_04 - everything works as expected now.
Hide
Permalink
Tom Rodriguez added a comment - 29/Aug/05 3:24 PM

Hello, I work for Sun on the Java VM and tripped across your report and decided to investigate the crash. I reproduced it in all Client VM configurations from 1.4.2 to mustang so it's a previously unreported bug. I've created bug 6317220 to track this issue in case you're interested.

Tom

Show
Tom Rodriguez added a comment - 29/Aug/05 3:24 PM Hello, I work for Sun on the Java VM and tripped across your report and decided to investigate the crash. I reproduced it in all Client VM configurations from 1.4.2 to mustang so it's a previously unreported bug. I've created bug 6317220 to track this issue in case you're interested. Tom
Hide
Permalink
Joerg Schaible added a comment - 12/Jan/06 6:08 PM

Seems to work now also for current 1.4.2 releases. Unit test fixture added to CollectionsTest.

Show
Joerg Schaible added a comment - 12/Jan/06 6:08 PM Seems to work now also for current 1.4.2 releases. Unit test fixture added to CollectionsTest.

People

  • Assignee:
    Unassigned
    Reporter:
    Holger Hoffstätte
Vote (0)
Watch (1)

Dates

  • Created:
    10/May/05 3:57 PM
    Updated:
    07/Aug/06 9:26 PM
    Resolved:
    12/Jan/06 6:08 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.