title: JAXB generic @XmlValue
body: <p>The goal is to produce the following XML with <a href="http://jaxb.java.net/guide/Mapping_interfaces.html">JAXB</a></p>
  
  <pre><code>&lt;foo&gt;
     &lt;bar&gt;string data&lt;/bar&gt;
     &lt;bar&gt;binary data&lt;/bar&gt;
  &lt;/foo&gt;
  </code></pre>
  
  <p>Is there a workaround to allow <strong>generic</strong> <a href="http://docs.oracle.com/javaee/5/api/javax/xml/bind/annotation/XmlValue.html"><code>@XmlValue</code></a> fields (I need to store <code>byte[]</code> and <code>String</code> data)? Below is what I desire:</p>
  
  <pre><code>@XmlRootElement
  public class Foo {
      private @XmlElement List&lt;Bar&gt; bars;
  }
  
  @XmlRootElement
  public class Bar&lt;T&gt; {
      private @XmlValue T value;  // (*)
  }
  </code></pre>
  
  <p>But I get this exception</p>
  
  <blockquote>
    <p>(*) IllegalAnnotationException:<br>
    @XmlAttribute/@XmlValue need to reference a Java type that maps to text in XML.</p>
  </blockquote>