1. XStream
  2. XSTR-393

XStream isn't consistent with Annotations.configureAliases method


    • Type: Bug Bug
    • Status: Closed Closed
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.3
    • Component/s: None
    • Labels:
    • JDK version and platform:
      Sun 1.5.0_06 for linux


      We've a XML file with one root node (and some other attributes), and 2, 3 level nodes with a process of reading (xstream.fromXML).
      a) The third level, before we change the business logic, it was a normal unique attribute. Configured the with Annotations.configureAliases(xstream, RootClassTest.class) was suficiently for the XStream find out all the other annotations in RootClassTest.class, and their HAS-A classes.
      Therefore, all attributes from XML were mapped to RootClassTest and their children, by a single Annotations.configureAliases() invocation.

      b) We changed the business logic and the 3 level attribute, named "objeto_postal", changed to List of "objeto_postal", thereby,
      A implicit Collection was configured in the RootClassTest's child class to understand it as a collection.
      The problem is that the system thrown a com.thoughtworks.xstream.mapper.CannotResolveClassException.

      I understood that inserting a Annotations.configureAliases for each Annotated class related in XML, the problem is solved, but
      some things are wrong, in contract terms:

      1) If the configureAliases is needed for the unique RootClass node, all the annotated class, in relation HAS-A and HAS-MANY, should
      be annotated automatic, not just HAS-A attributes. The main cause for this misunderstood is that configureAliases' javaDoc doesn't specify
      the contract: "All annotated class must be configured". Even more I configured HAS-A classes annotated that ran without to use configureAliases.

      2) If the configureAliases is needed for ALL topLevel nodes (when classes is annotated), so the framework doesn't cannot accept HAS-A annotated class not configured with.

      If the XStream framework report a correct Exception (class annotated but not configured...No alias or annotation found for the element XXX in XML's reader process), it will be fine.


        • Assignee:
          Jörg Schaible
          Jonatas Wingeter Rodrigues
        • Votes:
          0 Vote for this issue
          0 Start watching this issue


          • Created: