XStream
  1. XStream
  2. XSTR-444

@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

          People

          • Assignee:
            Unassigned
            Reporter:
            Felix Mayer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: