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