title: Why are static classes special in JAXB unmarshalling
body: <p>I have several cases where the class generated by JAXB from an xsd file has a series of lists of classes that also contain lists of classes. The class generated uses static inner classes when handling these cases, but this leads to several instances a class existing multiple times. </p>
  
  <p>As an example I have a Parameter class that exists in multiple xsd files. In every instance this parameter class is the same and contains a key vale pair. When generating code for each of these xsd files each generated class contains an inner class with the name Parameter.</p>
  
  <p>To reduce redundancy I have removed the Parameter class from all the generated classes, reimplemented it, and updated all of the references. <strong>This works as expected</strong></p>
  
  <p>Trouble occurs when I have another class such as LogicalDevice that is also implemented in several classes. LogicalDevice contains a ParameterList. When LogicalDevice is extracted to its own class, and the references are updated, only the first attribute in the Parameter class is maintained and the rest are null. </p>
  
  <p>This leads me to believe that there is something special with the static inner classes. </p>
  
  <p>For reference here is my xml and code</p>
  
  <pre><code>&lt;Jetstream xmlns="http://Jetstream.TersoSolutions.com/v1.1/GetPoliciesResponse"&gt;
      &lt;Header/&gt;
      &lt;GetPoliciesResponse&gt;
          &lt;PolicyList&gt;
              &lt;Policy Id="53bb663f-7ed0-41f8-9757-90ad4e015995" Name="MyPolicy"
                   DeviceDefinitionId="f3536a6d-4610-4d56-82d9-54fd6602a883" &gt;
                  &lt;ParameterList&gt;
                      &lt;Parameter Name="aggregateeventscancount" Value="2"/&gt;
                      &lt;Parameter Name="aggregateeventscantime" Value="10"/&gt;
                      &lt;Parameter Name="antenna1rxsensitivity" Value="50"/&gt;
                      &lt;Parameter Name="antenna1txpower" Value="30"/&gt;
                      &lt;Parameter Name="antenna2rxsensitivity" Value="50"/&gt;
                      &lt;Parameter Name="antenna2txpower" Value="30"/&gt;
                      &lt;Parameter Name="antenna3rxsensitivity" Value="50"/&gt;
                      &lt;Parameter Name="antenna3txpower" Value="30"/&gt;
                      &lt;Parameter Name="antenna4rxsensitivity" Value="50"/&gt;
                      &lt;Parameter Name="antenna4txpower" Value="30"/&gt;
                      &lt;Parameter Name="commandpollinterval" Value="60"/&gt;
                      &lt;Parameter Name="dns" Value="0.0.0.0"/&gt;
                      &lt;Parameter Name="dooropentimelimit" Value="300"/&gt;
                      &lt;Parameter Name="gateway" Value="0.0.0.0"/&gt;
                      &lt;Parameter Name="ip" Value="0.0.0.0"/&gt;
                      &lt;Parameter Name="jetstreamdeviceurl" Value="https://us-device.tersosolutions.com/v1.0/device/"/&gt;
                      &lt;Parameter Name="lockdownhightemp" Value="127"/&gt;
                      &lt;Parameter Name="lockdownonacpowerfailure" Value="0"/&gt;
                      &lt;Parameter Name="lockdownonreaderfailure" Value="0"/&gt;
                      &lt;Parameter Name="lockdownonhightemp" Value="0"/&gt;
                      &lt;Parameter Name="logentryeventhightemp" Value="127"/&gt;
                      &lt;Parameter Name="logentryeventlowtemp" Value="-128"/&gt;
                      &lt;Parameter Name="numberofantennas" Value="4"/&gt;
                      &lt;Parameter Name="logentrylevel" Value="Warning"/&gt;
                      &lt;Parameter Name="objecteventscancount" Value="2"/&gt;
                      &lt;Parameter Name="objecteventscantime" Value="10"/&gt;
                      &lt;Parameter Name="Subnet" Value="0.0.0.0"/&gt;
                  &lt;/ParameterList&gt;
                  &lt;LogicalDeviceList&gt;
                      &lt;LogicalDevice LogicalDeviceId="MyDevice"&gt;
                          &lt;ParameterList&gt;
                              &lt;Parameter Name="ip" value="192.168.91.100" /&gt;
                              &lt;Parameter Name="subnet" value="255.255.255.0" /&gt;
                              &lt;Parameter Name="gateway" value="192.168.91.1" /&gt;
                              &lt;Parameter Name="dns" value="192.168.91.2" /&gt;
                          &lt;/ParameterList&gt;
                      &lt;/LogicalDevice&gt;
                  &lt;/LogicalDeviceList&gt;
              &lt;/Policy&gt;
          &lt;/PolicyList&gt;
      &lt;/GetPoliciesResponse&gt;
  &lt;/Jetstream&gt;
  </code></pre>
  
  <p>The following is the modified generated code with the references updated. </p>
  
  <pre><code>//
  // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference     Implementation, v2.2.7 
  // See &lt;a href="http://java.sun.com/xml/jaxb"&gt;http://java.sun.com/xml/jaxb&lt;/a&gt; 
  // Any modifications to this file will be lost upon recompilation of the source schema. 
  // Generated on: 2013.09.09 at 10:24:32 AM CDT 
  //
  
  
  package com.TersoSolutions.Jetstream.SDK.XML.Model.GetPoliciesResponse;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  import javax.xml.bind.annotation.XmlAccessType;
  import javax.xml.bind.annotation.XmlAccessorType;
  import javax.xml.bind.annotation.XmlAnyAttribute;
  import javax.xml.bind.annotation.XmlAnyElement;
  import javax.xml.bind.annotation.XmlAttribute;
  import javax.xml.bind.annotation.XmlElement;
  import javax.xml.bind.annotation.XmlRootElement;
  import javax.xml.bind.annotation.XmlType;
  import javax.xml.namespace.QName;
  
  import com.TersoSolutions.Jetstream.SDK.XML.LogicalDeviceList;
  
  @XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "Jetstream", propOrder = {
  "header",
  "getPoliciesResponse"
  })
  @XmlRootElement(name = "Jetstream")
  public class Jetstream {
  
  @XmlElement(name = "Header", required = true)
  protected Jetstream.Header header;
  @XmlElement(name = "GetPoliciesResponse", required = true)
  protected Jetstream.GetPoliciesResponse getPoliciesResponse;
  
  /**
   * Gets the value of the header property.
   * 
   * @return
   *     possible object is
   *     {@link Jetstream.Header }
   *     
   */
  public Jetstream.Header getHeader() {
      return header;
  }
  
  /**
   * Gets the value of the getPoliciesResponse property.
   * 
   * @return
   *     possible object is
   *     {@link Jetstream.GetPoliciesResponse }
   *     
   */
  public Jetstream.GetPoliciesResponse getGetPoliciesResponse() {
      return getPoliciesResponse;
  }
  
  @XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "GetPoliciesResponse", propOrder = {
      "policyList",
      "any"
  })
  public static class GetPoliciesResponse {
  
      @XmlElement(name = "PolicyList", required = true)
      protected Jetstream.GetPoliciesResponse.PolicyList policyList;
      @XmlAnyElement(lax = true)
      protected List&lt;Object&gt; any;
      @XmlAnyAttribute
      private Map&lt;QName, String&gt; otherAttributes = new HashMap&lt;QName, String&gt;();
  
      /**
       * Gets the value of the policyList property.
       * 
       * @return
       *     possible object is
       *     {@link Jetstream.GetPoliciesResponse.PolicyList }
       *     
       */
      public Jetstream.GetPoliciesResponse.PolicyList getPolicyList() {
          return policyList;
      }
  
  
      @XmlAccessorType(XmlAccessType.FIELD)
      @XmlType(name = "PolicyList", propOrder = {
          "policy"
      })
      public static class PolicyList {
  
          @XmlElement(name = "Policy")
          protected List&lt;Jetstream.GetPoliciesResponse.PolicyList.Policy&gt; policy;
  
          /**
           * Gets the value of the policy property.
           * 
           * &lt;p&gt;
           * This accessor method returns a reference to the live list,
           * not a snapshot. Therefore any modification you make to the
           * returned list will be present inside the JAXB object.
           * This is why there is not a &lt;CODE&gt;set&lt;/CODE&gt; method for the policy property.
           * 
           * &lt;p&gt;
           * For example, to add a new item, do as follows:
           * &lt;pre&gt;
           *    getPolicy().add(newItem);
           * &lt;/pre&gt;
           * 
           * 
           * &lt;p&gt;
           * Objects of the following type(s) are allowed in the list
           * {@link Jetstream.GetPoliciesResponse.PolicyList.Policy }
           * 
           * 
           */
          public List&lt;Jetstream.GetPoliciesResponse.PolicyList.Policy&gt; getPolicy() {
              if (policy == null) {
                  policy = new ArrayList&lt;Jetstream.GetPoliciesResponse.PolicyList.Policy&gt;();
              }
              return this.policy;
          }
  
          @XmlAccessorType(XmlAccessType.FIELD)
          @XmlType(name = "Policy", propOrder = {
              "parameterList",
              "logicalDeviceList",
              "any"
          })
          public static class Policy {
  
              @XmlElement(name = "ParameterList", required = true)
              protected com.TersoSolutions.Jetstream.SDK.XML.ParameterList parameterList;
              @XmlElement(name = "LogicalDeviceList", required = true)
              protected LogicalDeviceList logicalDeviceList;
              @XmlAnyElement(lax = true)
              protected List&lt;Object&gt; any;
              @XmlAttribute(name = "Id", required = true)
              protected String id;
              @XmlAttribute(name = "Name", required = true)
              protected String name;
              @XmlAttribute(name = "DeviceDefinitionId", required = true)
              protected String deviceDefinitionId;
              @XmlAnyAttribute
              private Map&lt;QName, String&gt; otherAttributes = new HashMap&lt;QName, String&gt;();
  
              /**
               * Gets the value of the parameterList property.
               * 
               * @return
               *     possible object is
               *     {@link Jetstream.GetPoliciesResponse.PolicyList.Policy.ParameterList }
               *     
               */
              public com.TersoSolutions.Jetstream.SDK.XML.ParameterList getParameterList() {
                  return parameterList;
              }
  
              /**
               * Gets the value of the logicalDeviceList property.
               * 
               * @return
               *     possible object is
               *     {@link Jetstream.GetPoliciesResponse.PolicyList.Policy.LogicalDeviceList }
               *     
               */
              public LogicalDeviceList getLogicalDeviceList() {
                  return logicalDeviceList;
              }
  
              /**
               * Gets the value of the id property.
               * 
               * @return
               *     possible object is
               *     {@link String }
               *     
               */
              public String getId() {
                  return id;
              }
  
              /**
               * Gets the value of the name property.
               * 
               * @return
               *     possible object is
               *     {@link String }
               *     
               */
              public String getName() {
                  return name;
              }
  
              /**
               * Gets the value of the deviceDefinitionId property.
               * 
               * @return
               *     possible object is
               *     {@link String }
               *     
               */
              public String getDeviceDefinitionId() {
                  return deviceDefinitionId;
              }
  
          }
  
      }
  
  }
  
  @XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "Header")
  public static class Header {
  
      @XmlAnyAttribute
      private Map&lt;QName, String&gt; otherAttributes = new HashMap&lt;QName, String&gt;();
  
  }
  
  }
  </code></pre>
  
  <p>This is the updated Logical Device</p>
  
  <pre><code>package com.TersoSolutions.Jetstream.SDK.XML;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  import javax.xml.bind.annotation.XmlAccessType;
  import javax.xml.bind.annotation.XmlAccessorType;
  import javax.xml.bind.annotation.XmlAnyAttribute;
  import javax.xml.bind.annotation.XmlAttribute;
  import javax.xml.bind.annotation.XmlElement;
  import javax.xml.bind.annotation.XmlRootElement;
  import javax.xml.bind.annotation.XmlType;
  import javax.xml.namespace.QName;
  
  import com.TersoSolutions.Jetstream.SDK.XML.Model.GetConfigurationResponse.Jetstream;
  
  @XmlAccessorType(XmlAccessType.FIELD)
  @XmlRootElement(name = "LogicalDeviceList")
  public class LogicalDeviceList {
  
  @XmlElement(name = "LogicalDevice")
  protected List&lt;LogicalDevice&gt; logicalDevice;
  
  /**
   * Gets the value of the logicalDevice property.
   * 
   * &lt;p&gt;
   * This accessor method returns a reference to the live list,
   * not a snapshot. Therefore any modification you make to the
   * returned list will be present inside the JAXB object.
   * This is why there is not a &lt;CODE&gt;set&lt;/CODE&gt; method for the logicalDevice property.
   * 
   * &lt;p&gt;
   * For example, to add a new item, do as follows:
   * &lt;pre&gt;
   *    getLogicalDevice().add(newItem);
   * &lt;/pre&gt;
   * 
   * 
   * &lt;p&gt;
   * Objects of the following type(s) are allowed in the list
   * {@link Jetstream.GetConfigurationResponse.LogicalDeviceList.LogicalDevice }
   * 
   * 
   */
  public List&lt;LogicalDevice&gt; getLogicalDevice() {
      if (logicalDevice == null) {
          logicalDevice = new ArrayList&lt;LogicalDevice&gt;();
      }
      return this.logicalDevice;
  }
  
  @XmlAccessorType(XmlAccessType.FIELD)
  @XmlRootElement(name = "LogicalDevice")
  public static class LogicalDevice {
  
      @XmlElement(name = "ParameterList")
      protected com.TersoSolutions.Jetstream.SDK.XML.ParameterList parameterList;
      @XmlAttribute(name = "DeviceDefinitionId")
      protected String deviceDefinitionId;
      @XmlAttribute(name = "DeviceSerialNumber")
      protected String deviceSerialNumber;
      @XmlAttribute(name = "Health")
      protected String health;
      @XmlAttribute(name = "LogicalDeviceId", required = true)
      protected String logicalDeviceId;
      @XmlAttribute(name = "Region")
      protected String region;
      @XmlAttribute(name = "PolicyId")
      protected String policyId;
      @XmlAnyAttribute
      private Map&lt;QName, String&gt; otherAttributes = new HashMap&lt;QName, String&gt;();
  
      /**
       * Gets the value of the deviceDefinitionId property.
       * 
       * @return
       *     possible object is
       *     {@link String }
       *     
       */
      public String getDeviceDefinitionId() {
          return deviceDefinitionId;
      }
  
      /**
       * Gets the value of the deviceSerialNumber property.
       * 
       * @return
       *     possible object is
       *     {@link String }
       *     
       */
      public String getDeviceSerialNumber() {
          return deviceSerialNumber;
      }
  
      /**
       * Gets the value of the health property.
       * 
       * @return
       *     possible object is
       *     {@link String }
       *     
       */
      public String getHealth() {
          return health;
      }
  
  
      /**
       * Gets the value of the logicalDeviceId property.
       * 
       * @return
       *     possible object is
       *     {@link String }
       *     
       */
      public String getLogicalDeviceId() {
          return logicalDeviceId;
      }
  
  
      /**
       * Gets the value of the region property.
       * 
       * @return
       *     possible object is
       *     {@link String }
       *     
       */
      public String getRegion() {
          return region;
      }
  
  
      /**
       * Gets the value of the policyId property.
       * 
       * @return
       *     possible object is
       *     {@link String }
       *     
       */
      public String getPolicyId() {
          return policyId;
      }
  
      /**
       * Gets the value of the parameterList property.
       * 
       * @return
       *     possible object is
       *     {@link Jetstream.GetPoliciesResponse.PolicyList.Policy.LogicalDeviceList.LogicalDevice.ParameterList }
       *     
       */
      public com.TersoSolutions.Jetstream.SDK.XML.ParameterList getParameterList() {
          return parameterList;
      }
  
  }
  }
  </code></pre>
  
  <p>and finally the Parameter class</p>
  
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  @XmlRootElement(name = "ParameterList")
  public class ParameterList {
  
  @XmlElement(name = "Parameter", required = true)
  protected List&lt;com.TersoSolutions.Jetstream.SDK.XML.Parameter&gt; parameter;
  @XmlAnyAttribute
  private Map&lt;QName, String&gt; otherAttributes = new HashMap&lt;QName, String&gt;();
  
  /**
   * Gets the value of the parameter property.
   * 
   * &lt;p&gt;
   * This accessor method returns a reference to the live list,
   * not a snapshot. Therefore any modification you make to the
   * returned list will be present inside the JAXB object.
   * This is why there is not a &lt;CODE&gt;set&lt;/CODE&gt; method for the parameter property.
   * 
   * &lt;p&gt;
   * For example, to add a new item, do as follows:
   * &lt;pre&gt;
   *    getParameter().add(newItem);
   * &lt;/pre&gt;
   * 
   * 
   * &lt;p&gt;
   * Objects of the following type(s) are allowed in the list
   * {@link Jetstream.LogEntryEvent.LogEntryList.LogEntry.ParameterList.Parameter }
   * 
   * 
   */
  public List&lt;com.TersoSolutions.Jetstream.SDK.XML.Parameter&gt; getParameter() {
      if (parameter == null) {
          parameter = new ArrayList&lt;com.TersoSolutions.Jetstream.SDK.XML.Parameter&gt;();
      }
      return this.parameter;
  }
  
  @XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "Parameter")
  public static class Parameter {
  
      @XmlAttribute(name = "Name", required = true)
      protected String name;
      @XmlAttribute(name = "Value", required = true)
      protected String value;
      @XmlAnyAttribute
      private Map&lt;QName, String&gt; otherAttributes = new HashMap&lt;QName, String&gt;();
  
      /**
       * Gets the value of the name property.
       * 
       * @return
       *     possible object is
       *     {@link String }
       *     
       */
      public String getName() {
          return name;
      }
  
      /**
       * Gets the value of the value property.
       * 
       * @return
       *     possible object is
       *     {@link String }
       *     
       */
      public String getValue() {
          return value;
      }
  }
  }
  </code></pre>
  
  <p>To reiterate what is happening. The Parameter data contained within the Policy static class is there as expected, but the Parameter data under the LogicalDevice only contains the keys and all of the value data is set to null. </p>
  
  <p>Does anyone know why I am losing data with these changes, or what makes the static classes necessary. </p>