title: Java: Generic JAXB Serialization
body: <p>I'm looking for a generic way to serialize objects in Java using JAXB XML Serialization.  I'd like to have something like this:</p>
  
  <pre><code>public static &lt;T&gt; String serializeUsingJAXB(T entity) {
      JAXBContext context = JAXBContext.newInstance(T.class);
      // ...
  }
  </code></pre>
  
  <p>However, it looks as though due to type erasure, <code>T.class</code> doesn't work.</p>
  
  <p>What will?</p>