Details
-
Type: Bug
-
Status: Closed
-
Priority: Minor
-
Resolution: Fixed
-
Affects Version/s: 1.2.2
-
Fix Version/s: 1.3
-
Component/s: Annotations
-
Labels:None
-
JDK version and platform:1.6.0_02 for Windows
Description
The @XStreamAlias annotation is ignored during unmarshalling for @XStreamAsAttribute annotated fields of a base class. A quick example of the failure:
public abstract class BaseClass {
@XStreamAlias("guid")
@XStreamAsAttribute
private Integer id;
public Integer getId()
{ return id; }public void setId(Integer id)
{ this.id = id; }}
@XStreamAlias("foo")
public class Foo extends BaseClass {
@XStreamAlias("fooname")
@XStreamAsAttribute
private String name;
public Foo()
{ super(); }public String getName()
{ return name; }public void setName(String name)
{ this.name = name; }}
Marshalling a Foo object to xml produces the correct content:
<foo fooname="Name" guid="99"/>
Unmarshalling this exact output, however, produces a Foo object that has only the Name set correctly, not the id (aliased as guid in the super class). Id is left null.
I've attached an example Test program which demonstrates the break. Normal non-attribute fields' aliases are honored correctly from super classes, however.
Solved in the head revision. You may give it a try.