I *thought* I was using 1.4.7, but apparently was still on 1.4.4. When I updated to 1.4.7 the problem went away. Apologies!
-----Original Message----- From: Jörg Schaible [mailto:joerg.schai...@gmx.de] Sent: Thursday, July 17, 2014 5:30 PM To: user@xstream.codehaus.org Subject: [xstream-user] Re: Using XStream with class hierarchy in Java 8 gives incorrect results Hi Lesley, Lesley Perkins wrote: > Hello. I'm running into an issue with XStream starting with Java 8. This > works correctly in Java 7. Take the following example: > > import java.io.*; > > import com.thoughtworks.xstream.XStream; > import com.thoughtworks.xstream.io.xml.DomDriver; > > public class XStreamJre8 > { > > public static void main(String[] args) > { > Child child = new Child(2, 3); > > try > { > String fileName = new StringBuilder() > .append("child_") > .append(System.getProperty("java.version", "unknown")) > .append(".xml") > .toString(); > FileOutputStream out = new FileOutputStream(new File(fileName)); > XStream xStream = new XStream(new DomDriver()); > xStream.toXML(child, out); > out.close(); > } > catch (Exception e) > { > e.printStackTrace(); > } > } > > static class Parent > { > private int parentVar; > > public Parent () > { > this(-1); > } > > public Parent(int parentVar) > { > this.parentVar = parentVar; > } > > public int getParentVar() > { > return parentVar; > } > } // end class Parent > > static class Child extends Parent > { > private int childVar; > > public Child() > { > this(-1, -1); > } > > public Child(int parentVar, int childVar) > { > super(parentVar); > this.childVar = childVar; > } > > public int getChildVar() > { > return childVar; > } > } // end class Child > > } > > When I execute this with Java 7u51, my output is: > > <XStreamJre8_-Child> > <parentVar>2</parentVar> > <childVar>3</childVar> > </XStreamJre8_-Child> > > However, when I execute with Java 8u or 8u11, my output is: > > <XStreamJre8_-Child> > <childVar>3</childVar> > </XStreamJre8_-Child> > > You can see that the parent class is being ignored. I'm not sure what > changed that would cause this, but it's definitely an issue for me. Any > help/solutions would be appreciated. A lot of unit test would break in XStream if there is a general problem of this sort with Java 8, but the test suite runs perfectly with current Java 8 versions (https://bamboo-ci.codehaus.org/browse/XSTREAM). So, which version of XStream are you're using? Cheers, Jörg --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of Intercontinental Exchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.