title: Null Pointer Exception while unmarshalling XML with @XmlAnyElement annotation
body: <p>I'm currently trying to unmarshal some XML into a java object using JAXB and I'm getting a strange Null Pointer Exception. This is only an issue while unmarshalling. I can marshal with these classes just fine. Here are the relevant pieces of code (irrelevant portions are denoted by "..."):</p>
  
  <ol>
  <li><p>The JAXB Root element:</p>
  
  <pre><code>...
  @XmlRootElement(name="assets")
  public class Assets {
      String product;
      Images images = new Images();
  
      ...
  
      Public Assets() {}
  
      ...
  
      public String getProduct() { return this.product; }
  
      @XmlAttribute(name="product")
      public void setProduct(String newProduct) { this.product = newProduct; }
  
      public Images getImages() { return this.images; }
  
      @XmlElement(name="images")
      public void setImages(Images newImages) { this.images = newImages; }
  
      ...
  }
  </code></pre></li>
  <li><p>The Images sub-element of the root element:</p>
  
  <pre><code>...
  @XmlRootElement(name="images")
  @XmlSeeAlso(Image.class)
  @XmlType(propOrder = {"mainAsset", "image"})
  public class Images {
      List&lt;Image&gt; images;
      Image mainAsset;
  
      private static char counter = 'a';
      private static final String prefix = "product-image-";
  
      // Here's the part that causes the NPE
      @XmlAnyElement(lax=true)
      public List&lt;JAXBElement&lt;Image&gt;&gt; getImage() {
          final List&lt;JAXBElement&lt;Image&gt;&gt; imageList = new ArrayList&lt;JAXBElement&lt;Image&gt;&gt;();
          for (final Image g : this.images) {
              imageList.add(new JAXBElement(new QName(prefix + counter++), Image.class, g));
          }
          counter = 'a';
          return imageList;
      }
  
      @XmlElement(name="renditions")
      public void setImage(List&lt;Image&gt; newImages) { this.images = newImages; }
  
      public Image getMainAsset() { return this.mainAsset; }
  
      @XmlElement(name="main-asset-name")
      public void setMainAsset(Image newMainAsset) { this.mainAsset = newMainAsset; }
  }
  </code></pre></li>
  <li><p>The logic for unmarshalling the XML:</p>
  
  <pre><code>...
  public void modifyXML() {
  try {
      JAXBContext context = JAXBContext.newInstance(Assets.class, Images.class, Image.class);
      Unmarshaller um = context.createUnmarshaller();
      File f = new File("/path/to/my.xml");
      Assets assets = (Assets) um.unmarshal(f);
      ...
  } catch (JAXBException e) {
      e.printStackTrace();
  }
  }
  ...
  </code></pre></li>
  <li><p>Finally, the XML I'm trying to unmarshal (it might help to know that this xml file was actually generated using the JAXB marshaller, which runs without any problems):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;assets product="TEST PRODUCT"&gt;
      &lt;images&gt;
          &lt;main-asset-name&gt;
              &lt;path&gt;stuff.jpg&lt;/path&gt;
              &lt;title&gt;theTitle&lt;/path&gt;
              &lt;alt&gt;theAlt&lt;/path&gt;
              &lt;description&gt;theDescription&lt;/description&gt;
          &lt;/main-asset-name&gt;
          &lt;product-image-a&gt;
              &lt;path&gt;48x48.jpg&lt;/path&gt;
              &lt;title&gt;theTitle&lt;/path&gt;
              &lt;alt&gt;theAlt&lt;/path&gt;
              &lt;description&gt;theDescription&lt;/description&gt;
          &lt;/product-image-a&gt;
          &lt;product-image-b&gt;
              &lt;path&gt;140x140.jpg&lt;/path&gt;
              &lt;title&gt;theTitle&lt;/path&gt;
              &lt;alt&gt;theAlt&lt;/path&gt;
              &lt;description&gt;theDescription&lt;/description&gt;
          &lt;/product-image-b&gt;
          &lt;product-image-c&gt;
              &lt;path&gt;1280x1280.jpg&lt;/path&gt;
              &lt;title&gt;theTitle&lt;/path&gt;
              &lt;alt&gt;theAlt&lt;/path&gt;
              &lt;description&gt;theDescription&lt;/description&gt;
          &lt;/product-image-c&gt;
          &lt;product-image-d&gt;
              &lt;path&gt;319x319.jpg&lt;/path&gt;
              &lt;title&gt;theTitle&lt;/path&gt;
              &lt;alt&gt;theAlt&lt;/path&gt;
              &lt;description&gt;theDescription&lt;/description&gt;
          &lt;/product-image-d&gt;
      &lt;/images&gt;
  &lt;/assets&gt;
  </code></pre></li>
  </ol>
  
  <p>Okay, so that's all the relevant code (I think). When I run my program, I get the following error right after invoking the unmarshaller:</p>
  
  <pre><code>java.lang.NullPointerException
      at com.my.companys.name.Images.getImage(Images.java:25)
  </code></pre>
  
  <p>And the line number referenced is the line where the for loop starts in my <code>Images.java</code> class file.</p>
  
  <p>Does anyone have any ideas why <code>this.images</code> might be null here? Any help is greatly appreciated. Thanks ahead of time.</p>