XStream
  1. XStream
  2. XSTR-418

Attribute alias of super class ignored during unmarshal.

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor 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.

        Issue Links

          People

          • Assignee:
            Jörg Schaible
            Reporter:
            Matt Kinman
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: