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