XStream

@XStreamAlias ignored for fields in super classes

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Duplicate
  • Affects Version/s: 1.2.2
  • Fix Version/s: None
  • Component/s: Annotations
  • Labels:
    None
  • JDK version and platform:
    JDK 1.6.0 WIndows

Description

Suppose you have two classes A and B like this which are both declared with Annotations.configureAliases():

public abstract class A {
@XStreamAlias("test")
@XStreamAsAttribute
private String bug;
}

@XStreamAlias("concrete")
public class B extends A {
@XStreamAlias("firstName")
@XStreamAsAttribute
private String name;
}

Then XStream persists an instance of B like this:
<concrete firstName="michael" test="whatever"/>

Then XStream will not read the attribute 'test' from the XML document into the class since it expects the attribute name to be 'bug'. Basically the @XStreamAlias annotation is ignored in (abstract) super classes and the actual field name is used instead when the XML document is read; when an object is persisted, however, the @XStreamAlias annotation is used correctly.

Issue Links

Activity

Hide
Joerg Schaible added a comment -

See linked issue.

Show
Joerg Schaible added a comment - See linked issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: