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.
--Andy
________________________________
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.